音频文件未被Google语音解析 [英] audio file isn't being parsed with Google Speech
问题描述
这个问题是的后续行动以前的问题。
下面的代码片段几乎可以工作......它运行时没有错误,但还给出了 None
值为 results_list
。这意味着它正在访问文件(我认为),但不能从中提取任何东西。
我有一个文件, sample.wav
,在此处公开: https://storage.googleapis.com/ speech_proj_files / sample.wav
我试图通过指定 source_uri ='gs://speech_proj_files/sample.wav来访问它'
。
我不明白为什么这不起作用。我不认为这是一个权限问题。我的会话实例化很好。代码突然停顿了一下,但总是没有结果。我怎样才能调试呢?任何建议非常感谢。
from google.cloud导入语音
speech_client = speech.Client()
audio_sample = speech_client.sample(
content = None,
source_uri ='gs://speech_proj_files/sample.wav',
encoding ='LINEAR16',
sample_rate_hertz = 44100)
results_list = audio_sample.async_recognize(language_code ='en-US')
进口时间
from google.cloud import speech
speech_client = speech.Client()
sample = speech_client.sample(
content = None
, 'gs://speech_proj_files/sample.wav'
,encoding ='LINEAR16'
,sample_rate = 44100
,'languageCode':'en-US'
)
retry_count = 100
operation = sample.async_recognize(language_code ='en-US')
retry_count&g吨; 0而不是operation.complete:
retry_count - = 1
time.sleep(10)
operation.poll()#API调用
print(operation.complete )
print(operation.results [0] .transcript)
print(operation.results [0] .confidence)
for op in operation.results:
print op.transcript
然后像
for operation in operation.results:
print op.transcript
This question is a followup to a previous question.
The snippet of code below almost works...it runs without error yet gives back a None
value for results_list
. This means it is accessing the file (I think) but just can't extract anything from it.
I have a file, sample.wav
, living publicly here: https://storage.googleapis.com/speech_proj_files/sample.wav
I am trying to access it by specifying source_uri='gs://speech_proj_files/sample.wav'
.
I don't understand why this isn't working. I don't think it's a permissions problem. My session is instantiated fine. The code chugs for a second, yet always comes up with no result. How can I debug this?? Any advice is much appreciated.
from google.cloud import speech
speech_client = speech.Client()
audio_sample = speech_client.sample(
content=None,
source_uri='gs://speech_proj_files/sample.wav',
encoding='LINEAR16',
sample_rate_hertz= 44100)
results_list = audio_sample.async_recognize(language_code='en-US')
I finally got something to work:
import time
from google.cloud import speech
speech_client = speech.Client()
sample = speech_client.sample(
content = None
, 'gs://speech_proj_files/sample.wav'
, encoding='LINEAR16'
, sample_rate= 44100
, 'languageCode': 'en-US'
)
retry_count = 100
operation = sample.async_recognize(language_code='en-US')
while retry_count > 0 and not operation.complete:
retry_count -= 1
time.sleep(10)
operation.poll() # API call
print(operation.complete)
print(operation.results[0].transcript)
print(operation.results[0].confidence)
for op in operation.results:
print op.transcript
Then something like
for op in operation.results:
print op.transcript
这篇关于音频文件未被Google语音解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!