Googleの音声API Pythonはここで公開するために、私は例のコードを実行している:https://googlecloudplatform.github.io/google-cloud-python/stable/speech-usage.htmlGoogle Speech API Python例外:ファイルヘッダに一致するFLACエンコーディングを指定しますか?
を私は(のみ使用LINEAR16エンコーディングを可能にする)非同期認識方法のために行くよ:
は、Googleクラウドクライアントをインポート google.gax.errors.RetryError:ライブラリ
from google.cloud import speech
client = speech.Client()
sample = client.sample(source_uri='gs://my-bucket/example.flac',
encoding=speech.Encoding.LINEAR16,
sample_rate=44100)
operation = sample.async_recognize(language_code='es-CL',max_alternatives=2)
retry_count = 100
while retry_count > 0 and not operation.complete:
retry_count -= 1
time.sleep(10)
operation.poll() # API call
operation.complete
for result in operation.results:
for alternative in result.alternatives:
print('=' * 20)
print(alternative.transcript)
print(alternative.confidence)
は、これは私が取得していますエラーですGaxError(例外で終了RPCの< _Rendezvous(に起因する一時的なものとして分類されていなかったのリトライ方法、で発生しましたスタウトsCode.INVALID_ARGUMENT、ファイルヘッダに一致するFLACエンコーディングを指定してください。)>)
どうすればこの問題を解決できますか?同期メソッドを使用しているときにこの問題が発生していません。
パーフェクトです。私はsample_rateを8000に修正しなければなりませんでした。 – Rimo
素晴らしい仕事をしました。ありがとう@blambert – Stryker