Try fixing bad live transcription performance.
This commit is contained in:
@@ -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
@@ -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(() => {});
|
||||
|
||||
@@ -209,7 +209,13 @@ async function transcribe(message: TranscribeMessage): Promise<void> {
|
||||
}
|
||||
const asr = await active.promise;
|
||||
|
||||
const streamer = new WhisperTextStreamer(
|
||||
const options: Record<string, unknown> = {
|
||||
chunk_length_s: 30,
|
||||
stride_length_s: 5,
|
||||
return_timestamps: true,
|
||||
};
|
||||
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],
|
||||
{
|
||||
@@ -218,13 +224,7 @@ async function transcribe(message: TranscribeMessage): Promise<void> {
|
||||
post({ type: "partial", text, requestId: message.requestId }),
|
||||
},
|
||||
);
|
||||
|
||||
const options: Record<string, unknown> = {
|
||||
chunk_length_s: 30,
|
||||
stride_length_s: 5,
|
||||
return_timestamps: true,
|
||||
streamer,
|
||||
};
|
||||
}
|
||||
// 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") {
|
||||
|
||||
Reference in New Issue
Block a user