を持っています。コードは、.wavファイルを転記されたテキストに変換するのに十分でなければなりません。GoogleクラウドスピーチAPI Pythonのコードサンプルは、私はGoogleのスピーチAPI、<a href="https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/transcribe.py" rel="nofollow noreferrer">found here</a>から提供されたコードスニペットを通じて働いている可能バグ
注目ブロックはここにある:
def transcribe_file(speech_file):
"""Transcribe the given audio file."""
from google.cloud import speech
speech_client = speech.Client()
with io.open(speech_file, 'rb') as audio_file:
content = audio_file.read()
audio_sample = speech_client.sample(
content=content,
source_uri=None,
encoding='LINEAR16',
sample_rate_hertz=16000)
alternatives = audio_sample.recognize('en-US')
for alternative in alternatives:
print('Transcript: {}'.format(alternative.transcript))
まず、私は、おそらくコードが古いだと思う、とsample_rate_hertz=16000
はsample_rate=16000
に変更する必要がありました。その後
、私は、この行のエラーました:
alternatives = audio_sample.recognize('en-US')
AttributeError: 'Sample' object has no attribute 'recognize'
私はこれを修正する方法についての好奇心をお読みください。私はこの方法についての文書を見つけることができないようです。たぶんそれも交換する必要があります。
がありますので、[ここ](http://stackoverflow.com/questions/38703853/how-to-use-google-speech-recognition-api-in-python/38788928#38788928)を見てください。同様の動作例 –