Skip to content
Merged
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
2 changes: 2 additions & 0 deletions google/genai/_gaos/resources/interactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
from ...types.interactions.videoresponseformat import VideoResponseFormat
from ...types.interactions.webhookconfig import WebhookConfig
from ...types.interactions.wordinfo import WordInfo
from . import annotation
from . import codeexecutioncallstep
from . import codemenderagentconfig
from . import environment
Expand Down Expand Up @@ -224,6 +225,7 @@
"VideoResponseFormat",
"WebhookConfig",
"WordInfo",
"annotation",
"codeexecutioncallstep",
"codemenderagentconfig",
"environment",
Expand Down
22 changes: 22 additions & 0 deletions google/genai/_gaos/resources/interactions/annotation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
# pylint: skip-file

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from ....types.interactions.speechannotation import SpeechAnnotation as SpeechMetadata

__all__ = ["SpeechMetadata"]
5 changes: 5 additions & 0 deletions google/genai/_gaos/types/interactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
)
from .source import Source, SourceParam, SourceType
from .speakerconfig import SpeakerConfig, SpeakerConfigParam
from .speechannotation import SpeechAnnotation, SpeechAnnotationParam
from .speechconfig import SpeechConfig, SpeechConfigParam
from .staticmediaprocessing import StaticMediaProcessing, StaticMediaProcessingParam
from .status import Status, StatusParam
Expand Down Expand Up @@ -740,6 +741,8 @@
"SourceType",
"SpeakerConfig",
"SpeakerConfigParam",
"SpeechAnnotation",
"SpeechAnnotationParam",
"SpeechConfig",
"SpeechConfigParam",
"SpeechConfigUnion",
Expand Down Expand Up @@ -1156,6 +1159,8 @@
"SourceType": ".source",
"SpeakerConfig": ".speakerconfig",
"SpeakerConfigParam": ".speakerconfig",
"SpeechAnnotation": ".speechannotation",
"SpeechAnnotationParam": ".speechannotation",
"SpeechConfig": ".speechconfig",
"SpeechConfigParam": ".speechconfig",
"StaticMediaProcessing": ".staticmediaprocessing",
Expand Down
19 changes: 17 additions & 2 deletions google/genai/_gaos/types/interactions/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from __future__ import annotations
from .filecitation import FileCitation, FileCitationParam
from .placecitation import PlaceCitation, PlaceCitationParam
from .speechannotation import SpeechAnnotation, SpeechAnnotationParam
from .urlcitation import URLCitation, URLCitationParam
from .wordinfo import WordInfo, WordInfoParam
from functools import partial
Expand All @@ -33,7 +34,13 @@

AnnotationParam = TypeAliasType(
"AnnotationParam",
Union[URLCitationParam, PlaceCitationParam, WordInfoParam, FileCitationParam],
Union[
SpeechAnnotationParam,
URLCitationParam,
PlaceCitationParam,
WordInfoParam,
FileCitationParam,
],
)
r"""Citation information for model-generated content."""

Expand All @@ -51,13 +58,21 @@ class UnknownAnnotation(BaseModel):
_ANNOTATION_VARIANTS: dict[str, Any] = {
"file_citation": FileCitation,
"place_citation": PlaceCitation,
"speech_metadata": SpeechAnnotation,
"url_citation": URLCitation,
"word_info": WordInfo,
}


Annotation = Annotated[
Union[FileCitation, PlaceCitation, URLCitation, WordInfo, UnknownAnnotation],
Union[
FileCitation,
PlaceCitation,
SpeechAnnotation,
URLCitation,
WordInfo,
UnknownAnnotation,
],
BeforeValidator(
partial(
parse_open_union,
Expand Down
93 changes: 93 additions & 0 deletions google/genai/_gaos/types/interactions/speechannotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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
# pylint: skip-file

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .. import BaseModel, UNSET_SENTINEL
from ...utils import validate_const
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class SpeechAnnotationParam(TypedDict):
r"""Speech annotation for text content."""

end_index: NotRequired[int]
r"""End of the attributed segment, exclusive."""
speaker: NotRequired[str]
r"""The speaker to associate with this turn."""
start_index: NotRequired[int]
r"""Start of segment of the response that is attributed to this source.

Index indicates the start of the segment, measured in bytes.
"""
style: NotRequired[str]
r"""Style instruction for the speech synthesis."""
type: Literal["speech_metadata"]


class SpeechAnnotation(BaseModel):
r"""Speech annotation for text content."""

end_index: Optional[int] = None
r"""End of the attributed segment, exclusive."""

speaker: Optional[str] = None
r"""The speaker to associate with this turn."""

start_index: Optional[int] = None
r"""Start of segment of the response that is attributed to this source.

Index indicates the start of the segment, measured in bytes.
"""

style: Optional[str] = None
r"""Style instruction for the speech synthesis."""

type: Annotated[
Annotated[
Literal["speech_metadata"],
AfterValidator(validate_const("speech_metadata")),
],
pydantic.Field(alias="type"),
] = "speech_metadata"

@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["end_index", "speaker", "start_index", "style"])
serialized = handler(self)
m = {}

for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))

if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val

return m


try:
SpeechAnnotation.model_rebuild()
except NameError:
pass
9 changes: 9 additions & 0 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,9 @@ def _Part_to_mldev(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down Expand Up @@ -1623,6 +1626,9 @@ def _Part_to_vertex(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down Expand Up @@ -2066,4 +2072,7 @@ def _VoiceConfig_to_vertex(
getv(from_object, ['prebuilt_voice_config']),
)

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

return to_object
3 changes: 3 additions & 0 deletions google/genai/_tokens_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ def _Part_to_mldev(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down
3 changes: 3 additions & 0 deletions google/genai/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,9 @@ def _Part_to_mldev(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down
6 changes: 6 additions & 0 deletions google/genai/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ def _Part_to_mldev(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down Expand Up @@ -804,6 +807,9 @@ def _Part_to_vertex(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down
9 changes: 9 additions & 0 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,9 @@ def _Part_to_mldev(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down Expand Up @@ -3449,6 +3452,9 @@ def _Part_to_vertex(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down Expand Up @@ -4622,6 +4628,9 @@ def _VoiceConfig_to_vertex(
getv(from_object, ['prebuilt_voice_config']),
)

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

return to_object


Expand Down
6 changes: 6 additions & 0 deletions google/genai/tunings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,9 @@ def _Part_to_vertex(
to_object, ['mediaProcessing'], getv(from_object, ['media_processing'])
)

if getv(from_object, ['speech_metadata']) is not None:
setv(to_object, ['speechMetadata'], getv(from_object, ['speech_metadata']))

return to_object


Expand Down Expand Up @@ -2603,6 +2606,9 @@ def _VoiceConfig_to_vertex(
getv(from_object, ['prebuilt_voice_config']),
)

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

return to_object


Expand Down
Loading
Loading