Я пробую texttospeech с Google Cloud API. Вот пример кода, и он хорошо работает для английского языка; но когда я меняю language_code = 'en-US' на 'zh-CN' и устанавливаю входной текст на китайское слово, показываю ошибку: 400 Нет голоса TTS, соответствующего запросу TTS. Исправьте параметры выбора голоса и повторите попытку.
import argparse
# [START tts_synthesize_text]
def synthesize_text(text):
"""Synthesizes speech from the input string of text."""
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
input_text = texttospeech.types.SynthesisInput(text=text)
# Note: the voice can also be specified by name.
# Names of voices can be retrieved with client.list_voices().
voice = texttospeech.types.VoiceSelectionParams(
language_code='en-US',
ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)
audio_config = texttospeech.types.AudioConfig(
audio_encoding=texttospeech.enums.AudioEncoding.MP3)
response = client.synthesize_speech(input_text, voice, audio_config)
# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
out.write(response.audio_content)
print('Audio content written to file "output.mp3"')
# [END tts_synthesize_text]
Пожалуйста, помогите, как установить параметр, когда я использую китайский язык?