streamSpeechData method
Future<Stream<List<int> > >
streamSpeechData({
- required String input,
- required SpeechModel model,
- required SpeechVoice voice,
- String? instructions,
- SpeechResponseFormat? responseFormat,
- num? speed,
- String streamFormat = 'sse',
- List<
String> ? include,
Implementation
Future<Stream<List<int>>> streamSpeechData({
required String input,
required SpeechModel model,
required SpeechVoice voice,
String? instructions,
SpeechResponseFormat? responseFormat, // mp3 (default), opus, aac, flac, wav, pcm
num? speed, // 0.25 – 4.0 (default 1.0)
/// Leave as `"sse"` (the default here) unless you want raw audio frames.
String streamFormat = 'sse',
/// To receive `transcript.*` events include `"logprobs"` here.
List<String>? include,
}) async {
return await streamJsonData('/audio/speech', {
'stream': true, // tells the endpoint we want SSE
'input': input,
'model': model.toJson(),
'voice': voice.toJson(),
if (instructions != null) 'instructions': instructions,
if (responseFormat != null) 'response_format': responseFormat.toJson(),
if (speed != null) 'speed': speed,
'stream_format': "audio", // default here = "sse"
if (include != null) 'include': include,
});
}