mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:20:33 +08:00
* fix(voice): strip MediaRecorder codec params from STT uploads Chrome sends audio/webm;codecs=opus; OpenAI-compatible transcription APIs reject that as an unknown format. Fixes #945 * refactor(voice): normalize the STT MIME once, at the wire boundary The codec-parameter strip was applied at four layers: the recorder hook, the route, the `transcribe_audio` facade, and `_post_multipart`. Only the last of those decides what actually goes on the wire, and `openai_compat` is the sole registered STT adapter, so the two middle copies were pure duplication — and they made the route's contract ambiguous about who owns the value. Keep the client-side strip (it sets the Blob type, which is what the browser puts in the multipart part) and the adapter strip; drop the route and facade copies along with the now-unused facade re-export. The adapter-level test already pins the wire contract; the route test now asserts what the route actually promises — verbatim forwarding. --------- Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com> Co-authored-by: Frank <bingxizhao@novix.science>
11 lines
352 B
TypeScript
11 lines
352 B
TypeScript
/**
|
|
* MediaRecorder reports ``audio/webm;codecs=opus``. OpenAI-compatible STT
|
|
* endpoints treat the codec parameter as an unknown format and return 400.
|
|
*/
|
|
export function stripAudioMimeParameters(
|
|
mimeType: string | undefined | null,
|
|
): string {
|
|
const mediaType = (mimeType || "").split(";", 1)[0].trim();
|
|
return mediaType || "audio/webm";
|
|
}
|