Advanced
Speech Recognition Options

Speech Recognition Options

Model Configuration Options

OptionTypeDefaultDescription
languagestring'en'Target language for recognition
taskstring'transcribe'Task type ('transcribe' or 'translate')
onProgressfunction-Callback for loading progress updates
onCompletefunction-Callback when loading completes
onErrorfunction-Callback for error handling

Recording Parameters

ParameterTypeDefaultDescription
sampleRatenumber16000Audio sample rate
channelsnumber1Number of audio channels

Transcription Parameters

ParameterTypeDefaultDescription
return_timestampsbooleanfalseInclude word timestamps
chunk_length_snumber30Processing chunk length in seconds
stride_length_snumber5Overlap between chunks in seconds
languagestring'en'Force specific language

Example

const browserAI = new BrowserAI();
 
// Load Whisper model with options
await browserAI.loadModel('whisper-tiny-en', {
  language: 'en',
  task: 'transcribe',
  onProgress: (progress) => {
    console.log('Model loading:', progress.progress + '%'); // "Model loading: 60%"
  }
});
 
// Start recording with custom parameters
await browserAI.startRecording({
  sampleRate: 16000,
  channels: 1
});
 
// Transcribe with options
const audioBlob = await browserAI.stopRecording();
const transcription = await browserAI.transcribeAudio(audioBlob, {
  return_timestamps: true,
  chunk_length_s: 30,
  stride_length_s: 5,
  language: 'en'
});
 
console.log('Transcription Result:', transcription); 
// { text: "Hello world", timestamps: [...] }