Skip to content

Commit a72911a

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Add source_text to AudioTranscriptionConfig and SmartTranscriptionMode.
PiperOrigin-RevId: 1008477611
1 parent 8ddc655 commit a72911a

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

‎google/genai/_gaos/types/interactions/smarttranscriptionmode.py‎

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,64 @@
1818
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
1919

2020
from __future__ import annotations
21-
from .. import BaseModel
21+
from .. import BaseModel, UNSET_SENTINEL, current_exclude_none, serialize_with_info
2222
from ...utils import validate_const
23+
from ..basemodel import current_filtered_dump
2324
import pydantic
25+
from pydantic import model_serializer
2426
from pydantic.functional_validators import AfterValidator
25-
from typing import Literal
26-
from typing_extensions import Annotated, TypedDict
27+
from typing import Literal, Optional
28+
from typing_extensions import Annotated, NotRequired, TypedDict
2729

2830

2931
class SmartTranscriptionModeParam(TypedDict):
3032
r"""Configuration for smart transcription mode."""
3133

34+
source_text: NotRequired[str]
35+
r"""The source text to be edited or rewritten via voice instructions.
36+
When provided, the model performs voice-driven editing and outputs the
37+
finalized replacement text.
38+
"""
3239
type: Literal["smart"]
3340

3441

3542
class SmartTranscriptionMode(BaseModel):
3643
r"""Configuration for smart transcription mode."""
3744

45+
source_text: Optional[str] = None
46+
r"""The source text to be edited or rewritten via voice instructions.
47+
When provided, the model performs voice-driven editing and outputs the
48+
finalized replacement text.
49+
"""
50+
3851
type: Annotated[
3952
Annotated[Literal["smart"], AfterValidator(validate_const("smart"))],
4053
pydantic.Field(alias="type"),
4154
] = "smart"
4255

56+
@model_serializer(mode="wrap")
57+
def _serialize_model_with_info(self, handler, info):
58+
return serialize_with_info(self.serialize_model, handler, info)
59+
60+
def serialize_model(self, handler):
61+
optional_fields = set(["source_text"])
62+
exclude_none = current_exclude_none()
63+
skip_filtered = exclude_none is False or current_filtered_dump()
64+
serialized = handler(self)
65+
m = {}
66+
67+
for n, f in type(self).model_fields.items():
68+
k = f.alias if f.alias is not None else n
69+
if k not in serialized and n not in serialized and skip_filtered:
70+
continue
71+
val = serialized.get(k, serialized.get(n))
72+
73+
if val != UNSET_SENTINEL:
74+
if val is not None or k not in optional_fields:
75+
m[k] = val
76+
77+
return m
78+
4379

4480
try:
4581
SmartTranscriptionMode.model_rebuild()

‎google/genai/types.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6522,6 +6522,10 @@ class AudioTranscriptionConfig(_common.BaseModel):
65226522
default=None,
65236523
description="""Optional. Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If unspecified, defaults to `VERBATIM` transcription. In `SMART` mode, 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). Timestamps and diarization are incompatible with mode `SMART`.""",
65246524
)
6525+
source_text: Optional[str] = Field(
6526+
default=None,
6527+
description="""Optional. The source text to be edited or rewritten via voice instructions. When provided in `SMART` mode, the model evaluates the audio input against this text and emits the complete replacement text in the candidate response rather than appending to it.""",
6528+
)
65256529

65266530

65276531
class AudioTranscriptionConfigDict(TypedDict, total=False):
@@ -6553,6 +6557,9 @@ class AudioTranscriptionConfigDict(TypedDict, total=False):
65536557
mode: Optional[AudioTranscriptionConfigMode]
65546558
"""Optional. Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If unspecified, defaults to `VERBATIM` transcription. In `SMART` mode, 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). Timestamps and diarization are incompatible with mode `SMART`."""
65556559

6560+
source_text: Optional[str]
6561+
"""Optional. The source text to be edited or rewritten via voice instructions. When provided in `SMART` mode, the model evaluates the audio input against this text and emits the complete replacement text in the candidate response rather than appending to it."""
6562+
65566563

65576564
AudioTranscriptionConfigOrDict = Union[
65586565
AudioTranscriptionConfig, AudioTranscriptionConfigDict

0 commit comments

Comments
 (0)