Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions google/genai/_gaos/types/interactions/transcriptionconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
class TranscriptionConfigParam(TypedDict):
r"""Configuration for speech recognition (transcription)."""

language_hints: List[str]
r"""Required. BCP-47 language codes providing hints about the languages present in the
audio. At least one must be specified, or set to [\"auto\"] to enable
automatic language detection.
"""
adaptation_phrases: NotRequired[List[str]]
r"""Optional. A list of phrases to bias the ASR model towards."""
custom_vocabulary: NotRequired[List[str]]
Expand All @@ -40,6 +35,10 @@ class TranscriptionConfigParam(TypedDict):
"""
diarization_mode: NotRequired[str]
r"""Optional. Configures speaker diarization. Supported values: \"speaker\"."""
language_codes: NotRequired[List[str]]
r"""Optional. BCP-47 language codes providing hints about the languages present in the
audio. If omitted or empty, defaults to automatic language detection.
"""
timestamp_granularities: NotRequired[List[str]]
r"""Optional. The granularity of timestamps to include in the transcription output.
Supported values: \"word\". If empty, no timestamps are generated.
Expand All @@ -49,12 +48,6 @@ class TranscriptionConfigParam(TypedDict):
class TranscriptionConfig(BaseModel):
r"""Configuration for speech recognition (transcription)."""

language_hints: List[str]
r"""Required. BCP-47 language codes providing hints about the languages present in the
audio. At least one must be specified, or set to [\"auto\"] to enable
automatic language detection.
"""

adaptation_phrases: Annotated[
Optional[List[str]],
pydantic.Field(
Expand All @@ -71,6 +64,11 @@ class TranscriptionConfig(BaseModel):
diarization_mode: Optional[str] = None
r"""Optional. Configures speaker diarization. Supported values: \"speaker\"."""

language_codes: Optional[List[str]] = None
r"""Optional. BCP-47 language codes providing hints about the languages present in the
audio. If omitted or empty, defaults to automatic language detection.
"""

timestamp_granularities: Optional[List[str]] = None
r"""Optional. The granularity of timestamps to include in the transcription output.
Supported values: \"word\". If empty, no timestamps are generated.
Expand All @@ -83,6 +81,7 @@ def serialize_model(self, handler):
"adaptation_phrases",
"custom_vocabulary",
"diarization_mode",
"language_codes",
"timestamp_granularities",
]
)
Expand Down
56 changes: 4 additions & 52 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,6 @@
from ._common import set_value_by_path as setv


def _AudioTranscriptionConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['language_codes']) is not None:
raise ValueError(
'language_codes parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['language_auto']) is not None:
setv(to_object, ['languageAuto'], getv(from_object, ['language_auto']))

if getv(from_object, ['language_hints']) is not None:
setv(to_object, ['languageHints'], getv(from_object, ['language_hints']))

if getv(from_object, ['custom_vocabulary']) is not None:
setv(
to_object,
['customVocabulary'],
getv(from_object, ['custom_vocabulary']),
)

if getv(from_object, ['adaptation_phrases']) is not None:
setv(
to_object,
['adaptationPhrases'],
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


def _AuthConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -733,18 +693,14 @@ def _LiveClientSetup_to_mldev(
setv(
to_object,
['inputAudioTranscription'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['input_audio_transcription']), to_object
),
getv(from_object, ['input_audio_transcription']),
)

if getv(from_object, ['output_audio_transcription']) is not None:
setv(
to_object,
['outputAudioTranscription'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['output_audio_transcription']), to_object
),
getv(from_object, ['output_audio_transcription']),
)

if getv(from_object, ['proactivity']) is not None:
Expand Down Expand Up @@ -982,18 +938,14 @@ def _LiveConnectConfig_to_mldev(
setv(
parent_object,
['setup', 'inputAudioTranscription'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['input_audio_transcription']), to_object
),
getv(from_object, ['input_audio_transcription']),
)

if getv(from_object, ['output_audio_transcription']) is not None:
setv(
parent_object,
['setup', 'outputAudioTranscription'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['output_audio_transcription']), to_object
),
getv(from_object, ['output_audio_transcription']),
)

if getv(from_object, ['realtime_input_config']) is not None:
Expand Down
48 changes: 2 additions & 46 deletions google/genai/_tokens_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,6 @@
from ._common import set_value_by_path as setv


def _AudioTranscriptionConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['language_codes']) is not None:
raise ValueError(
'language_codes parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['language_auto']) is not None:
setv(to_object, ['languageAuto'], getv(from_object, ['language_auto']))

if getv(from_object, ['language_hints']) is not None:
setv(to_object, ['languageHints'], getv(from_object, ['language_hints']))

if getv(from_object, ['custom_vocabulary']) is not None:
setv(
to_object,
['customVocabulary'],
getv(from_object, ['custom_vocabulary']),
)

if getv(from_object, ['adaptation_phrases']) is not None:
setv(
to_object,
['adaptationPhrases'],
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


def _AuthConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -435,18 +395,14 @@ def _LiveConnectConfig_to_mldev(
setv(
parent_object,
['setup', 'inputAudioTranscription'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['input_audio_transcription']), to_object
),
getv(from_object, ['input_audio_transcription']),
)

if getv(from_object, ['output_audio_transcription']) is not None:
setv(
parent_object,
['setup', 'outputAudioTranscription'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['output_audio_transcription']), to_object
),
getv(from_object, ['output_audio_transcription']),
)

if getv(from_object, ['realtime_input_config']) is not None:
Expand Down
44 changes: 1 addition & 43 deletions google/genai/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,46 +34,6 @@
logger = logging.getLogger('google_genai.batches')


def _AudioTranscriptionConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['language_codes']) is not None:
raise ValueError(
'language_codes parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['language_auto']) is not None:
setv(to_object, ['languageAuto'], getv(from_object, ['language_auto']))

if getv(from_object, ['language_hints']) is not None:
setv(to_object, ['languageHints'], getv(from_object, ['language_hints']))

if getv(from_object, ['custom_vocabulary']) is not None:
setv(
to_object,
['customVocabulary'],
getv(from_object, ['custom_vocabulary']),
)

if getv(from_object, ['adaptation_phrases']) is not None:
setv(
to_object,
['adaptationPhrases'],
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


def _AuthConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -1226,9 +1186,7 @@ def _GenerateContentConfig_to_mldev(
setv(
to_object,
['audioTranscriptionConfig'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['audio_transcription_config']), to_object
),
getv(from_object, ['audio_transcription_config']),
)

return to_object
Expand Down
47 changes: 1 addition & 46 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,47 +65,6 @@ def _VideoGenerationReferenceType_to_mldev_enum_validate(
)


def _AudioTranscriptionConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
root_object: Optional[Union[dict[str, Any], object]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['language_codes']) is not None:
raise ValueError(
'language_codes parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['language_auto']) is not None:
setv(to_object, ['languageAuto'], getv(from_object, ['language_auto']))

if getv(from_object, ['language_hints']) is not None:
setv(to_object, ['languageHints'], getv(from_object, ['language_hints']))

if getv(from_object, ['custom_vocabulary']) is not None:
setv(
to_object,
['customVocabulary'],
getv(from_object, ['custom_vocabulary']),
)

if getv(from_object, ['adaptation_phrases']) is not None:
setv(
to_object,
['adaptationPhrases'],
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


def _AuthConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -1508,11 +1467,7 @@ def _GenerateContentConfig_to_mldev(
setv(
to_object,
['audioTranscriptionConfig'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['audio_transcription_config']),
to_object,
root_object,
),
getv(from_object, ['audio_transcription_config']),
)

return to_object
Expand Down
Loading
Loading