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
77 changes: 4 additions & 73 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 @@ -422,13 +382,6 @@ def _GenerationConfig_to_vertex(
' mode, not in Gemini Enterprise Agent Platform mode.'
)

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

return to_object


Expand Down Expand Up @@ -733,18 +686,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 +931,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 Expand Up @@ -1709,13 +1654,6 @@ def _Part_to_mldev(
if getv(from_object, ['part_metadata']) is not None:
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))

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

return to_object


Expand Down Expand Up @@ -1797,13 +1735,6 @@ def _Part_to_vertex(
' mode, not in Gemini Enterprise Agent Platform mode.'
)

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

return to_object


Expand Down
55 changes: 2 additions & 53 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 Expand Up @@ -608,13 +564,6 @@ def _Part_to_mldev(
if getv(from_object, ['part_metadata']) is not None:
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))

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

return to_object


Expand Down
Loading
Loading