Advanced
Text to Speech Options

Text-to-Speech Options

Model Configuration Options

OptionTypeDefaultDescription
qualitystring'medium'Model quality preset
onProgressfunction-Callback for loading progress updates
onCompletefunction-Callback when loading completes
onErrorfunction-Callback for error handling

Speech Generation Parameters

ParameterTypeDefaultDescription
voicestring'female_a'Voice selection
speednumber1.0Speech rate (0.5 - 2.0)
pitchnumber1.0Voice pitch adjustment
languagestring'en-US'Language code
qualitystring'medium'Audio quality preset
formatstring'wav'Output format

Example

const browserAI = new BrowserAI();
 
// Load TTS model with options
await browserAI.loadModel('speecht5-tts', {
  onProgress: (progress) => {
    console.log('Loading TTS model:', progress.progress + '%'); 
    // "Loading TTS model: 75%"
  }
});
 
// Generate speech with custom parameters
const audioBuffer = await browserAI.textToSpeech('Hello, how are you today?', {
  voice: 'female_a',
  speed: 1.2,
  pitch: 1.0,
  language: 'en-US',
  quality: 'high',
  format: 'wav'
});
 
console.log('Audio Status:', 'Generated successfully'); 
// "Audio Status: Generated successfully"