mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
Fix transcription sample-rate handling (#740)
Fix for #703. Adds an optional sampleRate parameter to the decodeAudioToFloat32() function. The caption transcriber passes in a value of 16000 to prepare audio in the format Whisper expects.
This commit is contained in:
@@ -34,10 +34,12 @@ export interface DecodedAudio {
|
||||
|
||||
export async function decodeAudioToFloat32({
|
||||
audioBlob,
|
||||
sampleRate,
|
||||
}: {
|
||||
audioBlob: Blob;
|
||||
sampleRate?: number;
|
||||
}): Promise<DecodedAudio> {
|
||||
const audioContext = createAudioContext();
|
||||
const audioContext = createAudioContext({ sampleRate });
|
||||
const arrayBuffer = await audioBlob.arrayBuffer();
|
||||
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user