google-cloud-speech - 需要帮助 Speech-to-text,重试次数过多总是失败

标签 google-cloud-speech

我使用 google 语音转文本 API 从音频中获取字幕,但是当音频太长时,通常超过 60 分钟,重试次数过多会失败。它说:google.api_core.exceptions.GoogleAPICallError: None Too many重试,放弃。

有人能帮我吗 ??

我试过很多次,当音频文件短于60分钟左右时,就可以了。

client = speech.SpeechClient()

# Loads audio into memory.
audio = types.RecognitionAudio(uri=gcs_uri)
config = types.RecognitionConfig(
    encoding=enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
    sample_rate_hertz=48000,
    language_code='en-US',
    enable_word_time_offsets=True,
    enable_automatic_punctuation=True)

# Detects speech in the audio file
operation = client.long_running_recognize(config, audio)
print('Waiting for operation to complete...')
# Get the feedback from Google Cloud API
operation.add_done_callback(callback)
time.sleep(30)
#metadata = operation.metadata
# Every 30 seconds to get back one response
percentile(operation, 30)

response = operation.result(timeout=None)

最佳答案

这是 operation.result() 调用抛出的异常。 operation.result() 调用有一个溢出的内部计数器。
在调用 operation.result() 之前尝试轮询 operation.done()。 operation.done() 是一个非阻塞调用。
希望这将在 google.cloud.speech 库的 future 版本中得到修复。

关于google-cloud-speech - 需要帮助 Speech-to-text,重试次数过多总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57433316/

相关文章:

java - 找不到谷歌包 "com.google.cloud.speech.v1beta1"

javascript - 谷歌云语音 api javascript/angular

java - 无法加载库: [netty_tcnative_linux_arm_32, netty_tcnative_linux_arm_32_fedora、netty_tcnative_arm_32、netty_tcnative]

Python:如何使用 pyaudio 获取 Google Cloud Speech API 的原始音频文件

android - 使用 API key 在 Android 上通过 GRPC 验证 Google Cloud Speech

python - 终端上Python的云异步语音识别错误

python - Google 的云语音 API 语音请求错误中出现异常

node.js - 谷歌云语音 API 不是从 base64 音频转录

ruby - 如何在成绩单中突出显示填充词(嗯,呃,啊)?

spring-mvc - Jetty ALPN/NPN 未正确配置。尝试使用 google cloud speech api 时