Не удалось найти сервер TTS для обработки запроса - PullRequest
0 голосов
/ 06 декабря 2018

Попытка сделать вывод на китайском языке.

google.api_core.exceptions.InvalidArgument: 400 Не удалось найти сервер TTS для обработки запроса application_id: 'cloud-tts' и trigger_application_id: '' и voice_request: language:«cmn-tw»

отлично работает с «en-US», но не работает с «cmn-tw»

Следуя примеру кода из Google Text-to-Speech APIКлиентские библиотеки

Ниже приведен мой код.

#!/usr/bin/python
#coding:utf-8
"""Synthesizes speech from the input string of text or ssml.

Note: ssml must be well-formed according to:
    https://www.w3.org/TR/speech-synthesis/
"""

from google.cloud import texttospeech

# Instantiates a client
client = texttospeech.TextToSpeechClient()

mytext = "這是一個測試"

# Set the text input to be synthesized
synthesis_input = texttospeech.types.SynthesisInput(text=mytext)

# Build the voice request, select the language code ("en-US") and the ssml
# voice gender ("neutral")
voice = texttospeech.types.VoiceSelectionParams(
    language_code='cmn-tw',
    ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)

# Select the type of audio file you want returned
audio_config = texttospeech.types.AudioConfig(
    audio_encoding=texttospeech.enums.AudioEncoding.MP3)

# Perform the text-to-speech request on the text input with the selected
# voice parameters and audio file type
response = client.synthesize_speech(synthesis_input, voice, audio_config)

# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
    # Write the response to the output file.
    out.write(response.audio_content)
    print('Audio content written to file "output.mp3"')
...