packages/docs/docs/whisper-web/resample-to-16khz.mdx
:::warning Unstable API: This package is experimental for the moment. As we test it, we might make a few changes to the API and switch to a WebGPU-based backend in the future. :::
Processes an audio File or Blob by decoding it, converting it to mono, and resampling it to a 16kHz Float32Array. This prepares the audio data for use with the transcribe() function.
This function operates in a browser environment as it relies on the Web Audio API (AudioContext, OfflineAudioContext) and FileReader.
fileThe audio File or Blob object that you want to process. The function will attempt to decode the audio from common formats (e.g., WAV, MP3, Ogg) supported by the browser's Web Audio API.
onProgress?A callback function that receives progress updates during the resampling process. The progress value is a number between 0 and 1, where 0 indicates the start and 1 indicates completion.
logLevel?Default: info
Type: 'trace' | 'verbose' | 'info' | 'warn' | 'error'
Optional. Determines the level of detail for logs printed to the console during the resampling process. Useful for debugging.
Promise<Float32Array>
This array contains the raw audio waveform data for a single channel (mono), sampled at 16kHz. This output is ready to be passed to the channelWaveform argument of the transcribe() function.
AudioContext, OfflineAudioContext) and FileReader.Float32Array at 16kHz, regardless of the input file's original channel count or sample rate.