Try fixing bad live transcription performance.

This commit is contained in:
Lucas Winther
2026-07-10 11:43:29 +02:00
parent db7b8a22c4
commit 2dff7512ac
3 changed files with 15 additions and 12 deletions
+3
View File
@@ -297,6 +297,9 @@ export function App() {
// live. `.en` models take neither (same rule as the file flow).
const options = (getModel(modelId)?.multilingual ?? false) ? { language, task } : {};
const transcriber = new LiveTranscriber({
tentativeIntervalMs: 2500,
minTentativeSeconds: 2.0,
segmenter: { commitSilenceSeconds: 2.5, maxSegmentSeconds: 29 },
transcribe: (audio) => transcribeLiveSegment(worker, audio, options),
onUpdate: (update) => {
setLiveCommitted(update.committedText);
+1 -1
View File
@@ -131,7 +131,7 @@ export async function startMicCapture(
audio: { echoCancellation: true, noiseSuppression: true, autoGainControl: true },
});
const context = new AudioContext();
const context = new AudioContext({ sampleRate: TARGET_SAMPLE_RATE });
// Contexts created outside a user gesture start suspended; the start button
// click satisfies the gesture requirement, so this resolves immediately.
await context.resume().catch(() => {});
+11 -11
View File
@@ -209,22 +209,22 @@ async function transcribe(message: TranscribeMessage): Promise<void> {
}
const asr = await active.promise;
const streamer = new WhisperTextStreamer(
// The ASR pipeline for Whisper models always carries a WhisperTokenizer.
asr.tokenizer as ConstructorParameters<typeof WhisperTextStreamer>[0],
{
skip_prompt: true,
callback_function: (text: string) =>
post({ type: "partial", text, requestId: message.requestId }),
},
);
const options: Record<string, unknown> = {
chunk_length_s: 30,
stride_length_s: 5,
return_timestamps: true,
streamer,
};
if (message.requestId === undefined) {
options.streamer = new WhisperTextStreamer(
// The ASR pipeline for Whisper models always carries a WhisperTokenizer.
asr.tokenizer as ConstructorParameters<typeof WhisperTextStreamer>[0],
{
skip_prompt: true,
callback_function: (text: string) =>
post({ type: "partial", text, requestId: message.requestId }),
},
);
}
// Only meaningful for multilingual models; the UI omits these for `.en`
// variants. "auto" / undefined lets Whisper detect the language.
if (message.language !== undefined && message.language !== "auto") {