小编DLI*_*I42的帖子

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

我使用 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)
Run Code Online (Sandbox Code Playgroud)

google-cloud-speech

7
推荐指数
1
解决办法
419
查看次数

标签 统计

google-cloud-speech ×1