Skip to content

Commit 1ac3c91

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Add source_text to AudioTranscriptionConfig and SmartTranscriptionMode.
PiperOrigin-RevId: 1013373084
1 parent 753cc1c commit 1ac3c91

2 files changed

Lines changed: 60 additions & 3 deletions

File tree

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

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,40 @@
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 (
24+
current_by_alias,
25+
current_filtered_dump,
26+
current_serialization_methods_dump,
27+
)
2328
import pydantic
29+
from pydantic import model_serializer
2430
from pydantic.functional_validators import AfterValidator
25-
from typing import Any, Literal
26-
from typing_extensions import Annotated, TypedDict
31+
from typing import Any, Literal, Optional
32+
from typing_extensions import Annotated, NotRequired, TypedDict
2733

2834

2935
class SmartTranscriptionModeParam(TypedDict):
3036
r"""Configuration for smart transcription mode."""
3137

38+
source_text: NotRequired[str]
39+
r"""The source text to be edited or rewritten via voice instructions.
40+
When provided, the model performs voice-driven editing and outputs the
41+
finalized replacement text.
42+
"""
3243
type: Literal["smart"]
3344

3445

3546
class SmartTranscriptionMode(BaseModel):
3647
r"""Configuration for smart transcription mode."""
3748

49+
source_text: Optional[str] = None
50+
r"""The source text to be edited or rewritten via voice instructions.
51+
When provided, the model performs voice-driven editing and outputs the
52+
finalized replacement text.
53+
"""
54+
3855
type: Annotated[
3956
Annotated[Literal["smart"], AfterValidator(validate_const("smart"))],
4057
pydantic.Field(alias="type"),
@@ -43,6 +60,39 @@ class SmartTranscriptionMode(BaseModel):
4360
def model_post_init(self, context: Any, /) -> None:
4461
self.__pydantic_fields_set__.update(["type"])
4562

63+
@model_serializer(mode="wrap")
64+
def _serialize_model_with_info(self, handler, info):
65+
return serialize_with_info(self.serialize_model, handler, info)
66+
67+
def serialize_model(self, handler):
68+
optional_fields = set(["source_text"])
69+
exclude_none = current_exclude_none()
70+
by_alias = current_by_alias()
71+
use_field_names = by_alias is False
72+
serialization_methods_dump = current_serialization_methods_dump()
73+
skip_filtered = (
74+
serialization_methods_dump
75+
or exclude_none is False
76+
or current_filtered_dump()
77+
)
78+
serialized = handler(self)
79+
m = {}
80+
81+
for n, f in type(self).model_fields.items():
82+
k = f.alias if f.alias is not None else n
83+
key = k if by_alias or k in serialized else n
84+
if key not in serialized and skip_filtered:
85+
continue
86+
val = serialized.pop(key, None)
87+
88+
if val != UNSET_SENTINEL:
89+
if val is not None or k not in optional_fields:
90+
m[n if use_field_names else k] = val
91+
for k, v in serialized.items():
92+
m[k] = v
93+
94+
return m
95+
4696

4797
try:
4898
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)