Filter out duplicate voices without language code in Google Cloud (#160046)

This commit is contained in:
tronikos
2025-12-31 07:30:53 -08:00
committed by GitHub
parent edd9f50562
commit 560b91b93b
2 changed files with 3 additions and 0 deletions

View File

@@ -48,6 +48,8 @@ async def async_tts_voices(
list_voices_response = await client.list_voices()
for voice in list_voices_response.voices:
language_code = voice.language_codes[0]
if not voice.name.startswith(language_code):
continue
if language_code not in voices:
voices[language_code] = []
voices[language_code].append(voice.name)

View File

@@ -81,6 +81,7 @@ def mock_api_tts() -> AsyncMock:
voices=[
cloud_tts.Voice(language_codes=["en-US"], name="en-US-Standard-A"),
cloud_tts.Voice(language_codes=["en-US"], name="en-US-Standard-B"),
cloud_tts.Voice(language_codes=["en-US"], name="Standard-A"),
cloud_tts.Voice(language_codes=["el-GR"], name="el-GR-Standard-A"),
]
)