中英翻译
yuanwu1454 opened this issue · 1 comments
yuanwu1454 commented
你好,我想知道这个怎么才能做到中英翻译。
self.config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=44100,
language_code='en-US',
max_alternatives=1,
enable_automatic_punctuation=True, # 启用标点符号
diarization_config=speaker_diarization_config, # 区分讲话人
speech_contexts=speech_contexts # 语音自适应
)
我将上述的 language_code 写成了 en-US
但是我发现我实时翻译这个的时候,http://127.0.0.1:5000 这个网页没有任何输出
Speech2text timeout
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "main.google.py", line 213, in run
for response in responses:
UnboundLocalError: local variable 'responses' referenced before assignment
127.0.0.1 - - [14/Jan/2021 03:46:17] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [14/Jan/2021 03:46:26] "GET / HTTP/1.1" 200 -
146 146 0 145 145 4 0
而且运行对应的脚本出现以上错误,想知道这个错误是怎么原因造成的?
从谷歌API收到回复 与 (翻译完成)的片段数 这两个字段总是 4和0
我这里播放的直播视频是英文视频可以请教一下如何解决这个问题吗?
azuse commented
你的报错
Speech2text timeout
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "main.google.py", line 213, in run
for response in responses:
UnboundLocalError: local variable 'responses' referenced before assignment
127.0.0.1 - - [14/Jan/2021 03:46:17] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [14/Jan/2021 03:46:26] "GET / HTTP/1.1" 200 -
146 146 0 145 145 4 0
Speech2text timeout
这里调语音转文字超时了,所以后面responses没有结果,才会referenced before assignment
前面连接youtube没出错,说明你代理应该没问题,那只能看看是不是GOOGLE_APPLICATION_CREDENTIALS配错了
参考https://cloud.google.com/docs/authentication/getting-started