model | String | 是 | 模型名称。 |
sampleRate | Integer | 是 | 采样率(Hz),支持任意采样率。 |
format | String | 是 | 音频格式。取值范围:
pcm
wav
mp3
opus
speex
aac
amr
opus/speex:必须使用Ogg封装;wav:必须为PCM编码;amr:仅支持AMR-NB类型。 |
keep_dialect | boolean | 否 | 仅 qwen-audio-3.1-asr-flash-streaming 支持。默认 false,将方言转写为普通话;设为 true 时保留方言表达。通过 .parameter("keep_dialect", value) 设置。完整参数说明请参见客户端事件。 |
vad_model | String | 否 | 仅 qwen-audio-3.1-asr-flash-streaming 支持。可选 near_meeting_16k(近场)或 far_field_meeting_16k(远场,默认值)。通过 .parameter("vad_model", value) 设置。完整参数说明请参见客户端事件。 |
vocabularyId | String | 否 | 预编译热词列表 ID。需预先调用创建热词列表接口生成,识别时传入该 ID 即可使用列表中的热词。适用于词汇已知且相对稳定、需要跨请求复用同一词表的场景。使用方法请参见预编译热词。 |
vocabulary | Map<String, Integer> | 否 | 即时热词。以键值对形式传入,键为热词文本(string),值为热词权重(integer),无需预先创建热词列表。权重取值范围为 [1, 5] 或 50:取 [1, 5] 时值越大模型越倾向输出该词;取 50 时为超级热词,召回率大幅提升,但超级热词数量最多不超过 50 个。适用于临时性、会话级别的热词优化。与预编译热词同时配置时,系统会合并两类热词;合并后超过 2000 个时,随机选择 2000 个使用。使用方法请参见即时热词。vocabulary需要通过 RecognitionParam 实例的 parameter 方法或者 parameters 方法进行设置:Map<String, Integer> vocab = new HashMap<>();
vocab.put("张三", 5);
vocab.put("李四", 5);
RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("vocabulary", vocab)
.build();
|
max_sentence_silence | Integer | 否 | VAD 断句静音阈值(ms)。当一段语音后的静音时长超过该阈值时,系统会判定该句子已结束。默认值:800。取值范围:[200, 6000]。max_sentence_silence需要通过RecognitionParam实例的parameter方法或者parameters方法进行设置:RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("max_sentence_silence", 800)
.build();
|
multi_threshold_mode_enabled | boolean | 否 | 是否启用多阈值模式。启用后可防止 VAD 断句切割过长。默认值:false。multi_threshold_mode_enabled需要通过RecognitionParam实例的parameter方法或者parameters方法进行设置:RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("multi_threshold_mode_enabled", true)
.build();
|
punctuation_prediction_enabled | boolean | 否 | 设置是否在识别结果中自动添加标点:punctuation_prediction_enabled需要通过RecognitionParam实例的parameter方法或者parameters方法进行设置:RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("punctuation_prediction_enabled", false)
.build();
|
heartbeat | boolean | 否 | 是否启用心跳包。默认值:false。
- true:在持续发送静音音频的情况下,可保持与服务端的连接不中断。
- false(默认):即使持续发送静音音频,连接也将在一定时间后因超时而断开。
静音音频指的是在音频文件或数据流中没有声音信号的内容。静音音频可以通过多种方法生成,例如使用音频编辑软件如Audacity或Adobe Audition,或者通过命令行工具如FFmpeg。heartbeat需要通过RecognitionParam实例的parameter方法或者parameters方法进行设置:RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("heartbeat", true)
.build();
|
language_hints | String[] | 否 | 待识别音频语种。无默认值,不设置时模型自动识别。最多支持设置 4 个值,超出时仅前 4 个生效。
- zh: 中文
- en: 英文
- ja: 日语
- ko:韩语
- vi:越南语
- th:泰语
- id:印尼语
- ms:马来语
- tl:菲律宾语
- hi:印地语
- ar:阿拉伯语
- fr:法语
- de:德语
- es:西班牙语
- pt:葡萄牙语
- ru:俄语
- it:意大利语
- nl:荷兰语
- sv:瑞典语
- da:丹麦语
- fi:芬兰语
- no:挪威语
- el:希腊语
- pl:波兰语
- cs:捷克语
- hu:匈牙利语
- ro:罗马尼亚语
- bg:保加利亚语
- hr:克罗地亚语
- sk:斯洛伐克语
language_hints需要通过RecognitionParam实例的parameter方法或者parameters方法进行设置:RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("language_hints", new String[]{"zh"})
.build();
|
speech_noise_threshold | float | 否 | 语音与噪音的判定阈值,用于调整语音活动检测(VAD)的灵敏度。取值范围:[-1.0, 1.0]。取值说明:
- 取值越接近 -1:降低噪音判定阈值,噪音被识别为语音的概率增大,可能导致更多噪音被转写
- 取值越接近 +1:提高噪音判定阈值,语音被误判为噪音的概率增大,可能导致部分语音被过滤
此参数为高级配置参数,调整可能显著影响识别效果,建议:
- 调整前充分测试验证效果
- 根据实际音频环境小幅度调整(建议步长 0.1)
speech_noise_threshold需要通过RecognitionParam实例的parameter方法或者parameters方法进行设置:RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("speech_noise_threshold", -0.5)
.build();
|
special_word_filter | String | 否 | 指定在语音识别过程中需要处理的敏感词,并支持对不同敏感词设置不同的处理方式。详情请参见敏感词过滤。special_word_filter需要通过RecognitionParam实例的parameter方法或者parameters方法进行设置:// 1. 构建最外层对象
JSONObject root = new JSONObject();
root.put("system_reserved_filter", true);
// 2. 构建“从结果中完全移除”的配置
JSONObject root1 = new JSONObject();
JSONArray array1 = new JSONArray();
array1.put("开始");
array1.put("进行");
root1.put("word_list", array1);
// 3. 构建“替换为等长 *”的配置
JSONObject root2 = new JSONObject();
JSONArray array2 = new JSONArray();
array2.put("测试");
root2.put("word_list", array2);
// 4. 组装
root.put("filter_with_empty", root1);
root.put("filter_with_signed", root2);
RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.parameter("special_word_filter", root.toString())
.build();
|
input | Map<String, Object> | 否 | 输入对象,用于传入对话上下文(context)。上下文用于辅助识别、提升专有词汇的识别准确率。使用方法详见提升识别准确率。Map 中需包含 context 键,值为 List<Map<String, Object>> 类型的消息数组,每条消息包含以下字段:
role(String,必选):消息角色。user 表示前几轮用户语音的识别结果或领域相关的词表;assistant 表示前几轮大语言模型的回复内容。
content(List<Map>,必选):消息内容列表。每个元素包含 type(String,role 为 user 时填 input_text,role 为 assistant 时填 text)和 text(String,文本内容)。
上下文消息(input_text 和 text 类型)各最多 5 条,超出时保留最近的 5 条。每轮上下文文本总长度不超过 400 个字符,超出部分从末尾截断。 携带上下文时,context 中的消息顺序有要求:上下文消息必须按对话轮次排列,每轮中 user(input_text 类型)必须在对应的 assistant(text 类型)之前。 input通过RecognitionParam实例的input方法进行设置:// 1. 构建 input 结构体
Map<String, Object> userContent = new HashMap<>();
userContent.put("type", "input_text");
userContent.put("text", "你好啊");
Map<String, Object> assistantContent = new HashMap<>();
assistantContent.put("type", "text");
assistantContent.put("text", "你好啊,我是通义千问,有什么可以帮助你的?");
Map<String, Object> userMessage = new HashMap<>();
userMessage.put("role", "user");
userMessage.put("content", Arrays.asList(userContent));
Map<String, Object> assistantMessage = new HashMap<>();
assistantMessage.put("role", "assistant");
assistantMessage.put("content", Arrays.asList(assistantContent));
Map<String, Object> input = new HashMap<>();
input.put("context", Arrays.asList(userMessage, assistantMessage));
// 2. 通过 input 方法传入
RecognitionParam param = RecognitionParam.builder()
.model("qwen-audio-3.1-asr-flash-streaming")
.format("pcm")
.sampleRate(16000)
.input(input)
.build();
|
apiKey | String | 否 | 用户API Key。 |