我将位于https://cloud.google.com/speech/docs/sync-recognize的google cloud speech api同步语音识别文档中的信息复制到我的代码中,但是当我运行代码时,我收到了很多错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/retry.py", line 121, in inner
return to_call(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/retry.py", line 68, in inner
return a_func(*updated_args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/grpc/_channel.py", line 487, in __call__
return _end_unary_response_blocking(state, call, False, deadline)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/grpc/_channel.py", line 437, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, sample_rate_hertz (16000) in RecognitionConfig must either be omitted or match the value in the WAV header ( 44100).)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "TESTINGAUDIO.py", line 27, in <module>
print (transcribe_file("output.wav"))
File "TESTINGAUDIO.py", line 20, in transcribe_file
response = client.recognize(config, audio)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/gapic/speech/v1/speech_client.py", line 201, in recognize
return self._recognize(request, options)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/api_callable.py", line 452, in inner
return api_caller(api_call, this_settings, request)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/api_callable.py", line 438, in base_caller
return api_call(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/api_callable.py", line 376, in inner
return a_func(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/retry.py", line 127, in inner
' classified as transient', exception)
google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, sample_rate_hertz (16000) in RecognitionConfig must either be omitted or match the value in the WAV header ( 44100).)>)
这是我的代码:
^{pr2}$有人能帮我修正这个错误吗?在
以下是接受索拉克建议后的第二批错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/retry.py", line 121, in inner
return to_call(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/retry.py", line 68, in inner
return a_func(*updated_args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/grpc/_channel.py", line 487, in __call__
return _end_unary_response_blocking(state, call, False, deadline)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/grpc/_channel.py", line 437, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Must use single channel (mono) audio, but WAV header indicates 2 channels.)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "TESTINGAUDIO.py", line 26, in <module>
print (transcribe_file("output.wav"))
File "TESTINGAUDIO.py", line 20, in transcribe_file
response = client.recognize(config, audio)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/gapic/speech/v1/speech_client.py", line 201, in recognize
return self._recognize(request, options)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/api_callable.py", line 452, in inner
return api_caller(api_call, this_settings, request)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/api_callable.py", line 438, in base_caller
return api_call(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/api_callable.py", line 376, in inner
return a_func(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/gax/retry.py", line 127, in inner
' classified as transient', exception)
google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Must use single channel (mono) audio, but WAV header indicates 2 channels.)>)
错误消息似乎在抱怨:
因为它指定的采样率与标准wav采样率44100冲突。它说这个值
^{pr2}$。。。如果你把那条线去掉会怎么样?在
相关问题 更多 >
编程相关推荐