Access the Typecast API with our official Dart and Flutter SDK.
The official Dart and Flutter SDK for the Typecast API. Convert text to lifelike speech, stream audio, generate timestamps, discover voices, and create custom voices from Dart or Flutter applications.
Use typecast_dart 0.1.0 or higher. For production Flutter apps, avoid embedding a long-lived API key in a distributed client. Route requests through your backend when the API key must remain private.
ssfm-v30 offers two emotion control modes: Preset and Smart.
Smart Mode
Preset Mode
Let the AI infer emotion from context:
final response = await client.textToSpeech( const TtsRequest( voiceId: 'tc_672c5f5ce59fac2a48faeaee', text: 'Everything is going to be okay.', model: TtsModel.ssfmV30, prompt: SmartPrompt( previousText: 'I just got the best news!', nextText: "I can't wait to celebrate!", ), ),);
Explicitly set emotion with preset values:
final response = await client.textToSpeech( const TtsRequest( voiceId: 'tc_672c5f5ce59fac2a48faeaee', text: 'I am so excited to show you these features!', model: TtsModel.ssfmV30, prompt: PresetPrompt( emotionPreset: EmotionPreset.happy, emotionIntensity: 1.5, ), ),);
final stream = await client.textToSpeechStream( const TtsRequestStream( voiceId: 'tc_672c5f5ce59fac2a48faeaee', text: 'Stream this text as audio in real time.', model: TtsModel.ssfmV30, output: OutputStream(audioFormat: AudioFormat.wav), ),);final file = File('stream.wav').openWrite();await for (final chunk in stream) { file.add(chunk);}await file.close();
WAV streaming format: 32000 Hz, 16-bit, mono PCM. The first chunk includes a 44-byte WAV header (size = 0xFFFFFFFF); subsequent chunks are raw PCM only. The streaming endpoint does not support volume or target_lufs.
textToSpeechWithTimestamps() wraps POST /v1/text-to-speech/with-timestamps and returns audio together with word- or character-level alignment data.
final result = await client.textToSpeechWithTimestamps( const TtsRequest( voiceId: 'tc_60e5426de8b95f1d3000d7b5', text: 'Hello. How are you?', model: TtsModel.ssfmV30, ),);await result.saveAudio('output.wav');print('Duration: ${result.audioDuration}s');for (final word in result.words) { print('[${word.startTime}s - ${word.endTime}s] ${word.word}');}
Pass granularity: 'word' (default) or granularity: 'char' to control the alignment unit.
final result = await client.textToSpeechWithTimestamps( const TtsRequest( voiceId: 'tc_60e5426de8b95f1d3000d7b5', text: 'Hello. How are you?', model: TtsModel.ssfmV30, ), granularity: 'char',);