fix(asr): 一句话识别 sourceType=1 时支持显式 voiceFormat(test-0415 反馈3-1 续修)
- 老逻辑:req.setVoiceFormat(getVoiceFormat(request.getUrl())) sourceType=1 时 url 为空 → 默认 wav → 把 mp3 数据当 wav 给腾讯云 → "Audio decoding failed" - 修复:TencentAsrRequest 新增 voiceFormat 字段(前端已透传 'mp3') ToolTencentAsrServiceImpl.sentenceRecognition 优先使用 request.getVoiceFormat(), 缺省回落到 getVoiceFormat(url) 兼容老调用 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -50,4 +50,7 @@ public class TencentAsrRequest {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "是否显示词级别时间戳")
|
@ApiModelProperty(value = "是否显示词级别时间戳")
|
||||||
private Boolean wordInfo;
|
private Boolean wordInfo;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "音频格式(sourceType=1 时必传:mp3/wav/m4a/aac/pcm/silk)", example = "mp3")
|
||||||
|
private String voiceFormat;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,13 @@ public class ToolTencentAsrServiceImpl implements ToolTencentAsrService {
|
|||||||
request.getEngineModelType() : asrConfig.getDefaultEngineModel());
|
request.getEngineModelType() : asrConfig.getDefaultEngineModel());
|
||||||
req.setSourceType(request.getSourceType() != null ?
|
req.setSourceType(request.getSourceType() != null ?
|
||||||
request.getSourceType().longValue() : 0L);
|
request.getSourceType().longValue() : 0L);
|
||||||
req.setVoiceFormat(getVoiceFormat(request.getUrl()));
|
// test-0415 反馈3-1:sourceType=1 时 url 为空,从 url 推断会默认 wav,导致 mp3 数据被当 wav 解 → "Audio decoding failed"
|
||||||
|
// 优先使用前端显式传入的 voiceFormat
|
||||||
|
String voiceFormat = request.getVoiceFormat();
|
||||||
|
if (voiceFormat == null || voiceFormat.isEmpty()) {
|
||||||
|
voiceFormat = getVoiceFormat(request.getUrl());
|
||||||
|
}
|
||||||
|
req.setVoiceFormat(voiceFormat);
|
||||||
|
|
||||||
if (request.getSourceType() != null && request.getSourceType() == 1) {
|
if (request.getSourceType() != null && request.getSourceType() == 1) {
|
||||||
req.setData(request.getData());
|
req.setData(request.getData());
|
||||||
|
|||||||
Reference in New Issue
Block a user