Skip to content

Commit

Permalink
feat: Add support for Python 3.13 (#13213)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

BEGIN_COMMIT_OVERRIDE
feat: Add multi-speaker markup, which allows generating dialogue between
multiple speakers
feat: Add support for Python 3.13
END_COMMIT_OVERRIDE

PiperOrigin-RevId: 689444598

Source-Link:
googleapis/googleapis@56f5fa4

Source-Link:
googleapis/googleapis-gen@532d282
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRleHR0b3NwZWVjaC8uT3dsQm90LnlhbWwiLCJoIjoiNTMyZDI4MjkxMmIxZWFmMTQxNTgxN2MwNjhlY2UyZTM1NGYwMDU1ZSJ9

Towards #13187

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 19dc048 commit 7cb80ba
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-texttospeech/.flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2023 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
10 changes: 6 additions & 4 deletions packages/google-cloud-texttospeech/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In order to add a feature:
documentation.

- The feature must work fully on the following CPython versions:
3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.
3.7, 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13 on both UNIX and Windows.

- The feature must not add unnecessary dependencies (where
"unnecessary" is of course subjective, but new dependencies should
Expand Down Expand Up @@ -72,7 +72,7 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.

- To run a single unit test::

$ nox -s unit-3.12 -- -k <name of test>
$ nox -s unit-3.13 -- -k <name of test>


.. note::
Expand Down Expand Up @@ -143,12 +143,12 @@ Running System Tests
$ nox -s system

# Run a single system test
$ nox -s system-3.12 -- -k <name of test>
$ nox -s system-3.13 -- -k <name of test>


.. note::

System tests are only configured to run under Python 3.8, 3.9, 3.10, 3.11 and 3.12.
System tests are only configured to run under Python 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13.
For expediency, we do not run them in older versions of Python 3.

This alone will not run the tests. You'll need to change some local
Expand Down Expand Up @@ -227,13 +227,15 @@ We support:
- `Python 3.10`_
- `Python 3.11`_
- `Python 3.12`_
- `Python 3.13`_

.. _Python 3.7: https://docs.python.org/3.7/
.. _Python 3.8: https://docs.python.org/3.8/
.. _Python 3.9: https://docs.python.org/3.9/
.. _Python 3.10: https://docs.python.org/3.10/
.. _Python 3.11: https://docs.python.org/3.11/
.. _Python 3.12: https://docs.python.org/3.12/
.. _Python 3.13: https://docs.python.org/3.13/


Supported versions can be found in our ``noxfile.py`` `config`_.
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-texttospeech/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2023 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-texttospeech/docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2023 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.19.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.19.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
grpc_version=None,
rest_version=requests_version,
rest_version=f"requests@{requests_version}",
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
grpc_version=None,
rest_version=requests_version,
rest_version=f"requests@{requests_version}",
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
CustomVoiceParams,
ListVoicesRequest,
ListVoicesResponse,
MultiSpeakerMarkup,
SsmlVoiceGender,
StreamingSynthesisInput,
StreamingSynthesizeConfig,
Expand Down Expand Up @@ -62,6 +63,7 @@
"CustomVoiceParams",
"ListVoicesRequest",
"ListVoicesResponse",
"MultiSpeakerMarkup",
"SsmlVoiceGender",
"StreamingSynthesisInput",
"StreamingSynthesizeConfig",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.19.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
grpc_version=None,
rest_version=requests_version,
rest_version=f"requests@{requests_version}",
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
grpc_version=None,
rest_version=requests_version,
rest_version=f"requests@{requests_version}",
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
CustomVoiceParams,
ListVoicesRequest,
ListVoicesResponse,
MultiSpeakerMarkup,
SsmlVoiceGender,
StreamingSynthesisInput,
StreamingSynthesizeConfig,
Expand Down Expand Up @@ -49,6 +50,7 @@
"CustomVoiceParams",
"ListVoicesRequest",
"ListVoicesResponse",
"MultiSpeakerMarkup",
"StreamingSynthesisInput",
"StreamingSynthesizeConfig",
"StreamingSynthesizeRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"SynthesizeSpeechRequest",
"CustomPronunciationParams",
"CustomPronunciations",
"MultiSpeakerMarkup",
"SynthesisInput",
"VoiceSelectionParams",
"AudioConfig",
Expand Down Expand Up @@ -355,6 +356,42 @@ class CustomPronunciations(proto.Message):
)


class MultiSpeakerMarkup(proto.Message):
r"""A collection of turns for multi-speaker synthesis.
Attributes:
turns (MutableSequence[google.cloud.texttospeech_v1beta1.types.MultiSpeakerMarkup.Turn]):
Required. Speaker turns.
"""

class Turn(proto.Message):
r"""A Multi-speaker turn.
Attributes:
speaker (str):
Required. The speaker of the turn, for
example, 'O' or 'Q'. Please refer to
documentation for available speakers.
text (str):
Required. The text to speak.
"""

speaker: str = proto.Field(
proto.STRING,
number=1,
)
text: str = proto.Field(
proto.STRING,
number=2,
)

turns: MutableSequence[Turn] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=Turn,
)


class SynthesisInput(proto.Message):
r"""Contains text input to be synthesized. Either ``text`` or ``ssml``
must be supplied. Supplying both or neither returns
Expand All @@ -381,6 +418,11 @@ class SynthesisInput(proto.Message):
For more information, see
`SSML <https://cloud.google.com/text-to-speech/docs/ssml>`__.
This field is a member of `oneof`_ ``input_source``.
multi_speaker_markup (google.cloud.texttospeech_v1beta1.types.MultiSpeakerMarkup):
The multi-speaker input to be synthesized.
Only applicable for multi-speaker synthesis.
This field is a member of `oneof`_ ``input_source``.
custom_pronunciations (google.cloud.texttospeech_v1beta1.types.CustomPronunciations):
Optional. The pronunciation customizations to
Expand Down Expand Up @@ -410,6 +452,12 @@ class SynthesisInput(proto.Message):
number=2,
oneof="input_source",
)
multi_speaker_markup: "MultiSpeakerMarkup" = proto.Field(
proto.MESSAGE,
number=4,
oneof="input_source",
message="MultiSpeakerMarkup",
)
custom_pronunciations: "CustomPronunciations" = proto.Field(
proto.MESSAGE,
number=3,
Expand Down
20 changes: 14 additions & 6 deletions packages/google-cloud-texttospeech/noxfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2023 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,15 @@

DEFAULT_PYTHON_VERSION = "3.10"

UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
UNIT_TEST_PYTHON_VERSIONS: List[str] = [
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
]
UNIT_TEST_STANDARD_DEPENDENCIES = [
"mock",
"asyncmock",
Expand All @@ -49,7 +57,7 @@
UNIT_TEST_EXTRAS: List[str] = []
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}

SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12"]
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
"mock",
"pytest",
Expand Down Expand Up @@ -168,7 +176,7 @@ def install_unittest_dependencies(session, *constraints):
def unit(session, protobuf_implementation):
# Install all test dependencies, then install this package in-place.

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"):
session.skip("cpp implementation is not supported in python 3.11+")

constraints_path = str(
Expand Down Expand Up @@ -368,15 +376,15 @@ def docfx(session):
)


@nox.session(python="3.12")
@nox.session(python="3.13")
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def prerelease_deps(session, protobuf_implementation):
"""Run all tests with prerelease versions of dependencies installed."""

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"):
session.skip("cpp implementation is not supported in python 3.11+")

# Install all dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-texttospeech",
"version": "2.19.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-texttospeech",
"version": "2.19.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2023 Google LLC All rights reserved.
# Copyright 2024 Google LLC All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions packages/google-cloud-texttospeech/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# See https://github.com/googleapis/google-cloud-python/issues/12364
"google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0",
"proto-plus >= 1.22.3, <2.0.0dev",
"proto-plus >= 1.25.0, <2.0.0dev; python_version >= '3.13'",
"protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
]
extras = {}
Expand Down Expand Up @@ -84,6 +85,7 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Topic :: Internet",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# This constraints file is required for unit tests.
# List all library dependencies and extras in this file.
google-api-core
proto-plus
protobuf

0 comments on commit 7cb80ba

Please sign in to comment.