diff --git a/google/genai/_live_converters.py b/google/genai/_live_converters.py index d3ca54c5e..bc43a6128 100644 --- a/google/genai/_live_converters.py +++ b/google/genai/_live_converters.py @@ -54,12 +54,6 @@ def _AudioTranscriptionConfig_to_mldev( 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 @@ -422,13 +416,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 @@ -1709,13 +1696,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 @@ -1797,13 +1777,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 diff --git a/google/genai/_tokens_converters.py b/google/genai/_tokens_converters.py index f408a8a3e..40b3fcb3e 100644 --- a/google/genai/_tokens_converters.py +++ b/google/genai/_tokens_converters.py @@ -54,12 +54,6 @@ def _AudioTranscriptionConfig_to_mldev( 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 @@ -608,13 +602,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 diff --git a/google/genai/batches.py b/google/genai/batches.py index eebf003f5..aa4dd36ee 100644 --- a/google/genai/batches.py +++ b/google/genai/batches.py @@ -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, @@ -1222,15 +1182,6 @@ def _GenerateContentConfig_to_mldev( if getv(from_object, ['service_tier']) is not None: setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) - if getv(from_object, ['audio_transcription_config']) is not None: - setv( - to_object, - ['audioTranscriptionConfig'], - _AudioTranscriptionConfig_to_mldev( - getv(from_object, ['audio_transcription_config']), to_object - ), - ) - return to_object @@ -1655,13 +1606,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 diff --git a/google/genai/caches.py b/google/genai/caches.py index d10fc2e27..9c441447e 100644 --- a/google/genai/caches.py +++ b/google/genai/caches.py @@ -789,13 +789,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 @@ -877,13 +870,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 diff --git a/google/genai/models.py b/google/genai/models.py index 7bb3a8aed..63fefc803 100644 --- a/google/genai/models.py +++ b/google/genai/models.py @@ -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, @@ -1504,17 +1463,6 @@ def _GenerateContentConfig_to_mldev( if getv(from_object, ['service_tier']) is not None: setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) - if getv(from_object, ['audio_transcription_config']) is not None: - setv( - to_object, - ['audioTranscriptionConfig'], - _AudioTranscriptionConfig_to_mldev( - getv(from_object, ['audio_transcription_config']), - to_object, - root_object, - ), - ) - return to_object @@ -1705,13 +1653,6 @@ def _GenerateContentConfig_to_vertex( if getv(from_object, ['service_tier']) is not None: setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) - if getv(from_object, ['audio_transcription_config']) is not None: - setv( - to_object, - ['audioTranscriptionConfig'], - getv(from_object, ['audio_transcription_config']), - ) - return to_object @@ -3059,13 +3000,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 @@ -3740,13 +3674,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 @@ -3829,13 +3756,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 diff --git a/google/genai/tunings.py b/google/genai/tunings.py index f41b89e17..8709df040 100644 --- a/google/genai/tunings.py +++ b/google/genai/tunings.py @@ -1242,13 +1242,6 @@ def _GenerationConfig_from_vertex( [item for item in getv(from_object, ['responseFormat'])], ) - if getv(from_object, ['audioTranscriptionConfig']) is not None: - setv( - to_object, - ['audio_transcription_config'], - getv(from_object, ['audioTranscriptionConfig']), - ) - return to_object @@ -1383,13 +1376,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 @@ -1581,13 +1567,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 diff --git a/google/genai/types.py b/google/genai/types.py index d5d04ea46..feffb5756 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -2103,95 +2103,6 @@ class VideoMetadataDict(TypedDict, total=False): VideoMetadataOrDict = Union[VideoMetadata, VideoMetadataDict] -class WordInfo(_common.BaseModel): - """Information about a single recognized word.""" - - word: Optional[str] = Field( - default=None, - description="""Transcript of the word. - """, - ) - start_offset: Optional[str] = Field( - default=None, - description="""Start offset in time of the word relative to the start of the audio. - """, - ) - end_offset: Optional[str] = Field( - default=None, - description="""End offset in time of the word relative to the start of the audio. - """, - ) - - -class WordInfoDict(TypedDict, total=False): - """Information about a single recognized word.""" - - word: Optional[str] - """Transcript of the word. - """ - - start_offset: Optional[str] - """Start offset in time of the word relative to the start of the audio. - """ - - end_offset: Optional[str] - """End offset in time of the word relative to the start of the audio. - """ - - -WordInfoOrDict = Union[WordInfo, WordInfoDict] - - -class Transcription(_common.BaseModel): - """Audio transcription in Server Content.""" - - text: Optional[str] = Field( - default=None, description="""Optional. Transcription text.""" - ) - finished: Optional[bool] = Field( - default=None, - description="""Optional. The bool indicates the end of the transcription.""", - ) - language_code: Optional[str] = Field( - default=None, - description="""The BCP-47 language code of the transcription.""", - ) - speaker_label: Optional[str] = Field( - default=None, - description="""A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2"). - """, - ) - words: Optional[list[WordInfo]] = Field( - default=None, - description="""Detailed word-level transcriptions and timing details. - """, - ) - - -class TranscriptionDict(TypedDict, total=False): - """Audio transcription in Server Content.""" - - text: Optional[str] - """Optional. Transcription text.""" - - finished: Optional[bool] - """Optional. The bool indicates the end of the transcription.""" - - language_code: Optional[str] - """The BCP-47 language code of the transcription.""" - - speaker_label: Optional[str] - """A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2"). - """ - - words: Optional[list[WordInfoDict]] - """Detailed word-level transcriptions and timing details. - """ - - -TranscriptionOrDict = Union[Transcription, TranscriptionDict] - - class Part(_common.BaseModel): """A datatype containing media content. @@ -2257,10 +2168,6 @@ class Part(_common.BaseModel): default=None, description="""Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.""", ) - audio_transcription: Optional[Transcription] = Field( - default=None, - description="""Output only. The transcription of the audio part.""", - ) def __init__( self, @@ -2492,9 +2399,6 @@ class PartDict(TypedDict, total=False): part_metadata: Optional[dict[str, Any]] """Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.""" - audio_transcription: Optional[TranscriptionDict] - """Output only. The transcription of the audio part.""" - PartOrDict = Union[Part, PartDict] @@ -6155,107 +6059,6 @@ class ModelArmorConfigDict(TypedDict, total=False): ModelArmorConfigOrDict = Union[ModelArmorConfig, ModelArmorConfigDict] -class LanguageAuto(_common.BaseModel): - """Indicates the language of the audio should be automatically detected.""" - - pass - - -class LanguageAutoDict(TypedDict, total=False): - """Indicates the language of the audio should be automatically detected.""" - - pass - - -LanguageAutoOrDict = Union[LanguageAuto, LanguageAutoDict] - - -class LanguageHints(_common.BaseModel): - """Provides hints to the model about possible languages present in the audio.""" - - language_codes: Optional[list[str]] = Field( - default=None, - description="""BCP-47 language codes. At least one must be specified.""", - ) - - -class LanguageHintsDict(TypedDict, total=False): - """Provides hints to the model about possible languages present in the audio.""" - - language_codes: Optional[list[str]] - """BCP-47 language codes. At least one must be specified.""" - - -LanguageHintsOrDict = Union[LanguageHints, LanguageHintsDict] - - -class AudioTranscriptionConfig(_common.BaseModel): - """The audio transcription configuration in Setup.""" - - language_codes: Optional[list[str]] = Field( - default=None, - description="""Deprecated: use LanguageAuto or LanguageHints instead.""", - ) - language_auto: Optional[LanguageAuto] = Field( - default=None, - description="""The model will detect the language automatically. Do not use together with LanguageHints.""", - ) - language_hints: Optional[LanguageHints] = Field( - default=None, - description="""Specifies one or more languages in the audio. Do not use together with LanguageAuto.""", - ) - custom_vocabulary: Optional[list[str]] = Field( - default=None, - description="""A list of custom vocabulary phrases, which biases the ASR model to improve recognition of these specific terms.""", - ) - adaptation_phrases: Optional[list[str]] = Field( - default=None, - description="""Deprecated. A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms.""", - ) - word_timestamp: Optional[bool] = Field( - default=None, - description="""Configures word-level timestamp generation. - """, - ) - diarization: Optional[bool] = Field( - default=None, - description="""Configures speaker diarization. - """, - ) - - -class AudioTranscriptionConfigDict(TypedDict, total=False): - """The audio transcription configuration in Setup.""" - - language_codes: Optional[list[str]] - """Deprecated: use LanguageAuto or LanguageHints instead.""" - - language_auto: Optional[LanguageAutoDict] - """The model will detect the language automatically. Do not use together with LanguageHints.""" - - language_hints: Optional[LanguageHintsDict] - """Specifies one or more languages in the audio. Do not use together with LanguageAuto.""" - - custom_vocabulary: Optional[list[str]] - """A list of custom vocabulary phrases, which biases the ASR model to improve recognition of these specific terms.""" - - adaptation_phrases: Optional[list[str]] - """Deprecated. A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms.""" - - word_timestamp: Optional[bool] - """Configures word-level timestamp generation. - """ - - diarization: Optional[bool] - """Configures speaker diarization. - """ - - -AudioTranscriptionConfigOrDict = Union[ - AudioTranscriptionConfig, AudioTranscriptionConfigDict -] - - class GenerateContentConfig(_common.BaseModel): """Optional model configuration parameters. @@ -6481,11 +6284,6 @@ class GenerateContentConfig(_common.BaseModel): default=None, description="""The service tier to use for the request. For example, ServiceTier.FLEX.""", ) - audio_transcription_config: Optional[AudioTranscriptionConfig] = Field( - default=None, - description="""Optional. Configuration for audio transcription (speech recognition). - """, - ) @pydantic.field_validator('response_schema', mode='before') @classmethod @@ -6703,10 +6501,6 @@ class GenerateContentConfigDict(TypedDict, total=False): service_tier: Optional[ServiceTier] """The service tier to use for the request. For example, ServiceTier.FLEX.""" - audio_transcription_config: Optional[AudioTranscriptionConfigDict] - """Optional. Configuration for audio transcription (speech recognition). - """ - GenerateContentConfigOrDict = Union[ GenerateContentConfig, GenerateContentConfigDict @@ -11332,11 +11126,6 @@ class GenerationConfig(_common.BaseModel): default=None, description="""Optional. Config for translation. This field is not supported in Vertex AI.""", ) - audio_transcription_config: Optional[AudioTranscriptionConfig] = Field( - default=None, - description="""Optional. Configuration for audio transcription (speech recognition). - """, - ) class GenerationConfigDict(TypedDict, total=False): @@ -11419,10 +11208,6 @@ class GenerationConfigDict(TypedDict, total=False): translation_config: Optional[TranslationConfigDict] """Optional. Config for translation. This field is not supported in Vertex AI.""" - audio_transcription_config: Optional[AudioTranscriptionConfigDict] - """Optional. Configuration for audio transcription (speech recognition). - """ - GenerationConfigOrDict = Union[GenerationConfig, GenerationConfigDict] @@ -20105,6 +19890,38 @@ class LiveServerSetupCompleteDict(TypedDict, total=False): ] +class Transcription(_common.BaseModel): + """Audio transcription in Server Content.""" + + text: Optional[str] = Field( + default=None, description="""Optional. Transcription text.""" + ) + finished: Optional[bool] = Field( + default=None, + description="""Optional. The bool indicates the end of the transcription.""", + ) + language_code: Optional[str] = Field( + default=None, + description="""The BCP-47 language code of the transcription.""", + ) + + +class TranscriptionDict(TypedDict, total=False): + """Audio transcription in Server Content.""" + + text: Optional[str] + """Optional. Transcription text.""" + + finished: Optional[bool] + """Optional. The bool indicates the end of the transcription.""" + + language_code: Optional[str] + """The BCP-47 language code of the transcription.""" + + +TranscriptionOrDict = Union[Transcription, TranscriptionDict] + + class LiveServerContent(_common.BaseModel): """Incremental server update generated by the model in response to client messages. @@ -20728,6 +20545,89 @@ class ContextWindowCompressionConfigDict(TypedDict, total=False): ] +class LanguageAuto(_common.BaseModel): + """Indicates the language of the audio should be automatically detected.""" + + pass + + +class LanguageAutoDict(TypedDict, total=False): + """Indicates the language of the audio should be automatically detected.""" + + pass + + +LanguageAutoOrDict = Union[LanguageAuto, LanguageAutoDict] + + +class LanguageHints(_common.BaseModel): + """Provides hints to the model about possible languages present in the audio.""" + + language_codes: Optional[list[str]] = Field( + default=None, + description="""BCP-47 language codes. At least one must be specified.""", + ) + + +class LanguageHintsDict(TypedDict, total=False): + """Provides hints to the model about possible languages present in the audio.""" + + language_codes: Optional[list[str]] + """BCP-47 language codes. At least one must be specified.""" + + +LanguageHintsOrDict = Union[LanguageHints, LanguageHintsDict] + + +class AudioTranscriptionConfig(_common.BaseModel): + """The audio transcription configuration in Setup.""" + + language_codes: Optional[list[str]] = Field( + default=None, + description="""Deprecated: use LanguageAuto or LanguageHints instead.""", + ) + language_auto: Optional[LanguageAuto] = Field( + default=None, + description="""The model will detect the language automatically. Do not use together with LanguageHints.""", + ) + language_hints: Optional[LanguageHints] = Field( + default=None, + description="""Specifies one or more languages in the audio. Do not use together with LanguageAuto.""", + ) + custom_vocabulary: Optional[list[str]] = Field( + default=None, + description="""A list of custom vocabulary phrases, which biases the ASR model to improve recognition of these specific terms.""", + ) + adaptation_phrases: Optional[list[str]] = Field( + default=None, + description="""Deprecated. A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms.""", + ) + + +class AudioTranscriptionConfigDict(TypedDict, total=False): + """The audio transcription configuration in Setup.""" + + language_codes: Optional[list[str]] + """Deprecated: use LanguageAuto or LanguageHints instead.""" + + language_auto: Optional[LanguageAutoDict] + """The model will detect the language automatically. Do not use together with LanguageHints.""" + + language_hints: Optional[LanguageHintsDict] + """Specifies one or more languages in the audio. Do not use together with LanguageAuto.""" + + custom_vocabulary: Optional[list[str]] + """A list of custom vocabulary phrases, which biases the ASR model to improve recognition of these specific terms.""" + + adaptation_phrases: Optional[list[str]] + """Deprecated. A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms.""" + + +AudioTranscriptionConfigOrDict = Union[ + AudioTranscriptionConfig, AudioTranscriptionConfigDict +] + + class ProactivityConfig(_common.BaseModel): """Config for proactivity features."""