SpeechConfig

@PublicPreviewAPI
public final class SpeechConfig


Speech configuration class for controlling the model's speech and audio generation behaviors.

This allows you to configure the voice properties (single-speaker OR multi-speaker setup) and language preferences when requesting the model to generate spoken responses.

Summary

Public fields

final String

The optional IETF BCP-47 language code (e.g., "en-US", "es-ES") used to guide the model's speech synthesis and recognition.

final MultiSpeakerVoiceConfig

The multi-speaker configuration.

final Voice

The single-speaker Voice configuration.

Public constructors

SpeechConfig(
    @NonNull MultiSpeakerVoiceConfig multiSpeakerVoiceConfig,
    String languageCode
)

Constructs a SpeechConfig for a multi-speaker setup.

SpeechConfig(@NonNull Voice voice, String languageCode)

Constructs a SpeechConfig for a single-speaker setup.

Public fields

languageCode

public final String languageCode

The optional IETF BCP-47 language code (e.g., "en-US", "es-ES") used to guide the model's speech synthesis and recognition.

multiSpeakerVoiceConfig

public final MultiSpeakerVoiceConfig multiSpeakerVoiceConfig

The multi-speaker configuration. Note that this configuration is not supported by the Live API (e.g., LiveGenerationConfig).

voice

public final Voice voice

The single-speaker Voice configuration.

Public constructors

SpeechConfig

public SpeechConfig(
    @NonNull MultiSpeakerVoiceConfig multiSpeakerVoiceConfig,
    String languageCode
)

Constructs a SpeechConfig for a multi-speaker setup.

Note: Multi-speaker configurations are not supported by the Live API (e.g., LiveGenerationConfig).

Parameters
@NonNull MultiSpeakerVoiceConfig multiSpeakerVoiceConfig

The configuration detailing multiple speakers and their corresponding voices.

String languageCode

An optional IETF BCP-47 language code to guide speech generation.

SpeechConfig

public SpeechConfig(@NonNull Voice voice, String languageCode)

Constructs a SpeechConfig for a single-speaker setup.

Parameters
@NonNull Voice voice

The specific Voice to use for speech generation.

String languageCode

An optional IETF BCP-47 language code to guide speech generation.