Reputation: 11
I need to make a speech recognition (in french) for a project and I choose the google speech api but I get the following error:
pi@raspberrypi:~ $ 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
first I install the google sdk and login with my account then I install google cloud speech for python with this line:
$ pip install --upgrade google-cloud-speech
And I got this error when I tried to launch this code:
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))
I follow these 2 pages:
google-cloud-speech 0.25.1
google-cloud client
Upvotes: 1
Views: 1183
Reputation: 11
You need to install the google-cloud client
sudo pip install google-cloud
That should do it
:~ $ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import speech
>>>
Upvotes: 1