1
我需要一個語音識別(法語)的一個項目,我選擇了谷歌語音API,但我得到了以下錯誤:試用谷歌語音API,但得到的客戶端模塊上一個ImportError
[email protected]:~ $ sudo python ~/sttG.py
Traceback (most recent call last):
File "sttG.py", line 1, in <module>
from google.cloud import speech
File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech/__init__.py", line 22, in <module>
from google.cloud.speech.client import Client
File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech/client.py", line 19, in <module>
from google.cloud.client import Client as BaseClient
ImportError: No module named client
第一我安裝谷歌SDK,並與我的帳號登錄 然後我安裝谷歌語音雲與此行蟒蛇:
$ pip install --upgrade google-cloud-speech
而且我得到了這個錯誤,當我嘗試啓動這個代碼:
from google.cloud import speech
client = speech.Client()
sample = client.sample(source_uri='gs://my-bucket/recording.flac',
encoding=speech.Encoding.FLAC,
sample_rate=44100)
results = sample.sync_recognize(
language_code='en-GB', max_alternatives=2)
for result in results:
for alternative in result.alternatives:
print('=' * 20)
print('transcript: ' + alternative.transcript)
print('confidence: ' + str(alternative.confidence))
我請按照下列2頁:
google-cloud-speech 0.25.1
google-cloud client