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

Cloud Asynchronous Speech Recognition Error with Python on terminal

我在同一个问题上花了大约 3 天时间。本质上,我正在尝试使用 google 云语音 api 对位于 gs://architecture-transcript-1/architecture.flac 的音频文件进行粗略转录 该文件以前是 m4a,但我将其转换为 flac 文件,它的采样率为 44100hz,持续 1 小时 18 分钟。

我是 运行 Python 3.5,正在使用命令提示符。我一直在使用的教程可以在这里找到:https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/README.rst

我已经完成了教程中的所有步骤,包括安装 pip 和 vitual env,安装依赖项,然后简单地使用创建的命令,"transcribe_async.py "。

在命令提示符中看起来像:

:\> virtualenv env
:\> virtualenv env/bin/activate
:\> cd C:\python-docs-samples-master\speech\cloud-client
C:\python-docs-samples-master\speech\cloud-client> pip install -r requirements.txt
C:\python-docs-samples-master\speech\cloud-client> python transcribe_async.py gs://architecture-transcript-1/architecture.flac 

在执行此操作之前,我进入 transcribe_async.py 文件以确保我的编码和文件格式匹配。
在 运行 之后,它说等待操作完成...然后得到这个最终错误:

File "transcribe_async.py", line 96, in <module>
transcribe_gcs(args.path)
File "transcribe_async.py", line 79, in transcribe_gcs
response = operation.result(timeout=90)
File "C:\Users\George\Anaconda3\lib\site-packages\google\gax\__init__.py", 
line 595, in result
if not self._poll(timeout).HasField('response'):
File "C:\Users\George\Anaconda3\lib\site-packages\google\gax\__init__.py", 
line 705, in _poll
return retryable_done_check()
File "C:\Users\George\Anaconda3\lib\site-packages\google\gax\retry.py", line 
143, in inner
raise exc
google.gax.errors.RetryError: RetryError(Retry total timeout exceeded with 
exception, caused by Deadline Exceeded)

主要错误好像是:"google.gax.errors.RetryError: RetryError(Retry total timeout exceeded with exception, caused by Deadline Exceeded)"

我在尝试使用 google python 代码创建音频文件时得到了这个。

我正在学习如何使用 Python,目前是我的第一年,所以这可能是初学者的错误,但是非常感谢您的帮助,因为我已经为此苦苦挣扎了一段时间!

P.S 目前我的文件是 public 所以如果直接尝试它有帮助,那仍然可用。

谢谢。

我不知道您用于转录的音频文件的持续时间。我建议您现在在 "transcribe_async.py"

中的第 79 行使用大量数字
response = operation.result(timeout=1000)

看看是否有帮助。

您可以考虑使用 Google Cloud SDK,目前有用于此目的的命令处于测试阶段

gcloud beta ml speech recognize gs://architecture-transcript-1/architecture.flac \
  --sample-rate 44100 --language en-US --encoding=FLAC