fix: mp-weixin 录音失败 - 权限声明+authorize+移除TS注解+空音频守卫

- interview.vue: 移除 `let recorder: any` TS 类型注解(小程序构建器不解析 TS,上次修改直接破坏构建从未部署)
- interview.vue: 合并两个 onMounted 调用,删除凭空引入的 refreshState() 未定义函数引用
- interview.vue: startRecord 增加 uni.authorize scope.record 权限预请求,拒绝时引导 openSetting
- interview.vue: recorder.start 改 wav/16kHz/128kbps(旧 aac/22050/16kbps 产生全 0 损坏文件)
- manifest.json: mp-weixin.permission 增加 scope.record 录音权限声明
- tts.controller.ts: ASR 拒绝 <500B 空音频文件,避免 whisper 调 ffmpeg 解码失败刷错日志
This commit is contained in:
yuzhiran
2026-07-05 01:57:24 +08:00
parent 4023c789b1
commit 31703af4f2
3 changed files with 91 additions and 34 deletions
@@ -47,6 +47,14 @@ export class TtsController {
const dest = path.join(uploadDir, file.filename + ext)
fs.renameSync(file.path, dest)
// 拒绝损坏/空音频文件,避免 whisper 调用 ffmpeg 解码失败刷错误日志
const stat = fs.statSync(dest)
if (!stat.size || stat.size < 500) {
this.logger.warn(`ASR: empty audio upload (size=${stat.size}), ext=${ext}`)
try { fs.unlinkSync(dest) } catch {}
return { text: '' }
}
let wavPath = dest
if (ext.toLowerCase() !== '.wav') {
const potentialWav = dest.replace(/\.[^.]+$/, '.wav')