buildGoogleTTS method
Builds a provider with GoogleTTSCapability
Returns a provider that implements GoogleTTSCapability for Google's native text-to-speech functionality.
Throws UnsupportedCapabilityError if the provider doesn't support Google TTS.
Example:
final ttsProvider = await ai()
.google((google) => google
.ttsModel('gemini-2.5-flash-preview-tts'))
.apiKey(apiKey)
.buildGoogleTTS();
// Direct usage without type casting
final response = await ttsProvider.generateSpeech(request);
Implementation
Future<GoogleTTSCapability> buildGoogleTTS() async {
final provider = await build();
if (provider is! GoogleTTSCapability) {
throw UnsupportedCapabilityError(
'Provider does not support Google TTS capabilities. '
'Make sure you are using a Google provider with a TTS-compatible model.',
);
}
return provider as GoogleTTSCapability;
}