Google Test to Speech не работает, ошибка: google.api_core.exceptions.DeadlineExceeded: 504 Крайний срок превышен - PullRequest
0 голосов
/ 01 марта 2020

Я пытаюсь запустить один образец в Google TTS на моем компьютере с windows 10 с python 3.7, он не работает. Я настроил каждый шаг как официальную страницу https://cloud.google.com/text-to-speech/docs/quickstart-client-libraries, но когда я запустил файл python в качестве образца на странице, он не удался.

пример кода, как показано ниже: имя файла: ggtts.py

"""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()

# Set the text input to be synthesized
synthesis_input = texttospeech.types.SynthesisInput(text="Hello, World!")

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

# 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"')

Ошибка, как показано ниже:

Traceback (most recent call last):
  File "D:\Program Files\Python\Python37\lib\site-packages\google\api_core\grpc_helpers.py", line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "D:\Program Files\Python\Python37\lib\site-packages\grpc\_channel.py", line 826, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "D:\Program Files\Python\Python37\lib\site-packages\grpc\_channel.py", line 729, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.DEADLINE_EXCEEDED
    details = "Deadline Exceeded"
    debug_error_string = "{"created":"@1583048623.437000000","description":"Deadline Exceeded","file":"src/core/ext/filters/deadline/deadline_filter.cc","file_line":69,"grpc_status":4}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\files\mypyfile\ggtts.py", line 26, in <module>
    response = client.synthesize_speech(synthesis_input, voice, audio_config)
  File "D:\Program Files\Python\Python37\lib\site-packages\google\cloud\texttospeech_v1\gapic\text_to_speech_client.py", line 322, in synthesize_speech
    request, retry=retry, timeout=timeout, metadata=metadata
  File "D:\Program Files\Python\Python37\lib\site-packages\google\api_core\gapic_v1\method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "D:\Program Files\Python\Python37\lib\site-packages\google\api_core\retry.py", line 286, in retry_wrapped_func
    on_error=on_error,
  File "D:\Program Files\Python\Python37\lib\site-packages\google\api_core\retry.py", line 184, in retry_target
    return target()
  File "D:\Program Files\Python\Python37\lib\site-packages\google\api_core\timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "D:\Program Files\Python\Python37\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded
>>> 

Кажется, ошибка возникла из

response = client.synthesize_speech(synthesis_input, voice, audio_config)

Я новичок в Google API , не знакомы с их кодами, кто-нибудь, пожалуйста, помогите, спасибо

...