fix(aihr): keep asr text when audio storage fails

This commit is contained in:
2026-07-14 16:41:45 +08:00
parent 26f5160802
commit ad21e24ed3
4 changed files with 10 additions and 3 deletions
@@ -54,8 +54,13 @@ public class AihrSpeechController {
}
return speechService.transcribe(file.getBytes(), file.getOriginalFilename(), file.getContentType())
.map(text -> {
SysOssVo oss = ossService.upload(file);
return R.ok(new AsrResponse(text, "openai-compatible", oss.getOssId(), oss.getUrl()));
try {
SysOssVo oss = ossService.upload(file);
return R.ok(new AsrResponse(text, "openai-compatible", oss.getOssId(), oss.getUrl()));
} catch (Exception e) {
log.warn("asr audio upload failed(处理错误已隐藏)");
return R.ok(new AsrResponse(text, "openai-compatible"));
}
})
.orElseGet(() -> R.fail("语音识别失败,请改用文字输入"));
}
@@ -60,6 +60,7 @@ class AihrSensitiveTextTest {
assertTrue(interviewSource.contains("AihrSensitiveText.personName(candidate.name(), \"候选人\")"));
assertTrue(speechSource.contains("AihrSensitiveText.forModel(text.trim())"));
assertTrue(speechSource.contains("asr http {}(外部响应体已隐藏)"));
assertTrue(speechControllerSource.contains("asr audio upload failed(处理错误已隐藏)"));
assertTrue(speechControllerSource.contains("tts audio upload failed(处理错误已隐藏)"));
assertTrue(orgSyncSource.contains("外部响应体已隐藏"));
assertTrue(orgSyncSource.contains("外部组织接口请求失败(处理错误已隐藏)"));