diff --git a/google/genai/_gaos/resources/interactions/__init__.py b/google/genai/_gaos/resources/interactions/__init__.py index 5bdf1ef5e..f5de80186 100644 --- a/google/genai/_gaos/resources/interactions/__init__.py +++ b/google/genai/_gaos/resources/interactions/__init__.py @@ -97,6 +97,7 @@ from ...types.interactions.toolchoiceconfig import ToolChoiceConfig from ...types.interactions.toolchoicetype import ToolChoiceType from ...types.interactions.transcriptionconfig import TranscriptionConfig +from ...types.interactions.transcriptionmode import TranscriptionMode from ...types.interactions.urlcitation import URLCitation from ...types.interactions.urlcontextcallarguments import URLContextCallArguments from ...types.interactions.urlcontextcallstep import URLContextCallStep @@ -201,6 +202,7 @@ "ToolChoiceConfig", "ToolChoiceType", "TranscriptionConfig", + "TranscriptionMode", "URLCitation", "URLContextCallArguments", "URLContextCallStep", diff --git a/google/genai/_gaos/types/interactions/__init__.py b/google/genai/_gaos/types/interactions/__init__.py index 71bfd6481..c93129d00 100644 --- a/google/genai/_gaos/types/interactions/__init__.py +++ b/google/genai/_gaos/types/interactions/__init__.py @@ -366,6 +366,7 @@ from .toolchoiceconfig import ToolChoiceConfig, ToolChoiceConfigParam from .toolchoicetype import ToolChoiceType from .transcriptionconfig import TranscriptionConfig, TranscriptionConfigParam + from .transcriptionmode import TranscriptionMode from .urlcitation import URLCitation, URLCitationParam from .urlcontext import URLContext, URLContextParam from .urlcontextcallarguments import ( @@ -732,6 +733,7 @@ "ToolParam", "TranscriptionConfig", "TranscriptionConfigParam", + "TranscriptionMode", "Transform", "TransformParam", "URLCitation", @@ -1117,6 +1119,7 @@ "ToolChoiceType": ".toolchoicetype", "TranscriptionConfig": ".transcriptionconfig", "TranscriptionConfigParam": ".transcriptionconfig", + "TranscriptionMode": ".transcriptionmode", "URLCitation": ".urlcitation", "URLCitationParam": ".urlcitation", "URLContext": ".urlcontext", diff --git a/google/genai/_gaos/types/interactions/interaction.py b/google/genai/_gaos/types/interactions/interaction.py index 8aeb5d50a..fd87df6fb 100644 --- a/google/genai/_gaos/types/interactions/interaction.py +++ b/google/genai/_gaos/types/interactions/interaction.py @@ -45,7 +45,7 @@ from .webhookconfig import WebhookConfig, WebhookConfigParam from functools import partial import pydantic -from pydantic import ConfigDict, model_serializer, model_validator +from pydantic import ConfigDict, model_serializer from pydantic.functional_validators import BeforeValidator from typing import Any, Dict, List, Literal, Optional, Union from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict @@ -387,7 +387,7 @@ def _maybe_coerce_outputs(cls, data: Any) -> Any: coerced["steps"] = [{"type": "model_output", "content": outputs}] return coerced - @model_validator(mode="before") + @pydantic.model_validator(mode="before") @classmethod def _coerce_outputs_to_steps(cls, data: Any) -> Any: return cls._maybe_coerce_outputs(data) @@ -396,9 +396,11 @@ def _coerce_outputs_to_steps(cls, data: Any) -> Any: def model_construct(cls, _fields_set=None, **values): # Coerce legacy lyria ``outputs`` -> ``steps`` here as well: validators # do not run on model_construct (used by deferred SSE parsing). - return super().model_construct(_fields_set, **cls._maybe_coerce_outputs(values)) + return pydantic.BaseModel.model_construct( + _fields_set, **cls._maybe_coerce_outputs(values) + ) - @model_validator(mode="after") + @pydantic.model_validator(mode="after") def _populate_output_helpers(self): steps = self.steps if isinstance(self.steps, list) else [] diff --git a/google/genai/_gaos/types/interactions/transcriptionconfig.py b/google/genai/_gaos/types/interactions/transcriptionconfig.py index f86a67495..99d9747d0 100644 --- a/google/genai/_gaos/types/interactions/transcriptionconfig.py +++ b/google/genai/_gaos/types/interactions/transcriptionconfig.py @@ -18,6 +18,7 @@ from __future__ import annotations from .. import BaseModel, UNSET_SENTINEL +from .transcriptionmode import TranscriptionMode import pydantic from pydantic import model_serializer from typing import List, Optional @@ -39,6 +40,11 @@ class TranscriptionConfigParam(TypedDict): r"""Optional. BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection. """ + mode: NotRequired[TranscriptionMode] + r"""Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If + unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with + `timestamp_granularities` and `diarization_mode`. + """ 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. @@ -69,6 +75,12 @@ class TranscriptionConfig(BaseModel): audio. If omitted or empty, defaults to automatic language detection. """ + mode: Optional[TranscriptionMode] = None + r"""Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If + unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with + `timestamp_granularities` and `diarization_mode`. + """ + 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. @@ -82,6 +94,7 @@ def serialize_model(self, handler): "custom_vocabulary", "diarization_mode", "language_codes", + "mode", "timestamp_granularities", ] ) diff --git a/google/genai/_gaos/types/interactions/transcriptionmode.py b/google/genai/_gaos/types/interactions/transcriptionmode.py new file mode 100644 index 000000000..a78842a6e --- /dev/null +++ b/google/genai/_gaos/types/interactions/transcriptionmode.py @@ -0,0 +1,34 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pyformat: disable + +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .. import UnrecognizedStr +from typing import Literal, Union + + +TranscriptionMode = Union[ + Literal[ + "verbatim", + "smart", + ], + UnrecognizedStr, +] +r"""Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If +unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with +`timestamp_granularities` and `diarization_mode`. +""" diff --git a/google/genai/types.py b/google/genai/types.py index 474117fdf..4a37ec61b 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -1358,6 +1358,17 @@ class VoiceActivityType(_common.CaseInSensitiveEnum): """End of sentence signal.""" +class AudioTranscriptionConfigMode(_common.CaseInSensitiveEnum): + """Transcription mode.""" + + MODE_UNSPECIFIED = 'MODE_UNSPECIFIED' + """Unspecified transcription mode.""" + VERBATIM = 'VERBATIM' + """Verbatim transcription mode.""" + SMART = 'SMART' + """Smart transcription mode.""" + + class StartSensitivity(_common.CaseInSensitiveEnum): """Start of speech sensitivity.""" @@ -6369,6 +6380,17 @@ class AudioTranscriptionConfig(_common.BaseModel): description="""Configures speaker diarization. """, ) + mode: Optional[AudioTranscriptionConfigMode] = Field( + default=None, + description="""Optional. Transcription mode. + + When set to `SMART`, the model performs disfluency removal (eliminating + filler words, repetitions, and false starts), light grammatical cleanup, + automatic formatting (paragraphs, bullet points, numbered lists), and + minor user edits (inline self-corrections). Incompatible with + `word_timestamp` and `diarization`. + """, + ) class AudioTranscriptionConfigDict(TypedDict, total=False): @@ -6397,6 +6419,16 @@ class AudioTranscriptionConfigDict(TypedDict, total=False): """Configures speaker diarization. """ + mode: Optional[AudioTranscriptionConfigMode] + """Optional. Transcription mode. + + When set to `SMART`, the model performs disfluency removal (eliminating + filler words, repetitions, and false starts), light grammatical cleanup, + automatic formatting (paragraphs, bullet points, numbered lists), and + minor user edits (inline self-corrections). Incompatible with + `word_timestamp` and `diarization`. + """ + AudioTranscriptionConfigOrDict = Union[ AudioTranscriptionConfig, AudioTranscriptionConfigDict