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).
|
// live. `.en` models take neither (same rule as the file flow).
|
||||||
const options = (getModel(modelId)?.multilingual ?? false) ? { language, task } : {};
|
const options = (getModel(modelId)?.multilingual ?? false) ? { language, task } : {};
|
||||||
const transcriber = new LiveTranscriber({
|
const transcriber = new LiveTranscriber({
|
||||||
|
tentativeIntervalMs: 2500,
|
||||||
|
minTentativeSeconds: 2.0,
|
||||||
|
segmenter: { commitSilenceSeconds: 2.5, maxSegmentSeconds: 29 },
|
||||||
transcribe: (audio) => transcribeLiveSegment(worker, audio, options),
|
transcribe: (audio) => transcribeLiveSegment(worker, audio, options),
|
||||||
onUpdate: (update) => {
|
onUpdate: (update) => {
|
||||||
setLiveCommitted(update.committedText);
|
setLiveCommitted(update.committedText);
|
||||||
|
|||||||
+1
-1
@@ -131,7 +131,7 @@ export async function startMicCapture(
|
|||||||
audio: { echoCancellation: true, noiseSuppression: true, autoGainControl: true },
|
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
|
// Contexts created outside a user gesture start suspended; the start button
|
||||||
// click satisfies the gesture requirement, so this resolves immediately.
|
// click satisfies the gesture requirement, so this resolves immediately.
|
||||||
await context.resume().catch(() => {});
|
await context.resume().catch(() => {});
|
||||||
|
|||||||
@@ -209,22 +209,22 @@ async function transcribe(message: TranscribeMessage): Promise<void> {
|
|||||||
}
|
}
|
||||||
const asr = await active.promise;
|
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> = {
|
const options: Record<string, unknown> = {
|
||||||
chunk_length_s: 30,
|
chunk_length_s: 30,
|
||||||
stride_length_s: 5,
|
stride_length_s: 5,
|
||||||
return_timestamps: true,
|
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`
|
// Only meaningful for multilingual models; the UI omits these for `.en`
|
||||||
// variants. "auto" / undefined lets Whisper detect the language.
|
// variants. "auto" / undefined lets Whisper detect the language.
|
||||||
if (message.language !== undefined && message.language !== "auto") {
|
if (message.language !== undefined && message.language !== "auto") {
|
||||||
|
|||||||
Reference in New Issue
Block a user