4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

エニプラAdvent Calendar 2021

Day 17

cloudspeech_demo.pyがAttributeErrorで実行できない【Google AIY Voice Kit】

Last updated at Posted at 2022-01-04

Google AIY Voice Kitにて、音声認識のデモアプリ(cloudpeech_demo.py)公式サイトの手順に沿ってやっているのにAttributeErrorで実行できない!

■エラー

pi@raspberrypi:~/AIY-projects-python/src/examples/voice $ ./cloudspeech_demo.py
Traceback (most recent call last):
  File "./cloudspeech_demo.py", line 22, in <module>
    from aiy.cloudspeech import CloudSpeechClient
  File "/home/pi/AIY-projects-python/src/aiy/cloudspeech.py", line 40, in <module>
    END_OF_SINGLE_UTTERANCE = speech.types.StreamingRecognizeResponse.END_OF_SINGLE_UTTERANCE
AttributeError: module 'google.cloud.speech' has no attribute 'types'

■解決方法
cloudspeech.pyを書き換える

■解決手順
①下記コマンドを入力し、cloudspeech.pyが存在するディレクトリまで移動する
cd ~/AIY-projects-python/src/aiy
②下記コマンドを入力し、cloudspeech.pyを編集する
vi cloudspeech.py
③画像の三箇所を書き換える
(1)

-from google.cloud import speech
+from google.cloud import speech_v1 as speech

(2)

-END_OF_SINGLE_UTTERANCE = speech.types.StreamingRecognizeResponse.END_OF_SINGLE_UTTERANCE
+END_OF_SINGLE_UTTERANCE = speech.types.StreamingRecognizeResponse.SpeechEventType.END_OF_SINGLE_UTTERANCE

(3)

-encoding=speech.types.RecognitionConfig.LINEAR16,
+encoding=speech.types.RecognitionConfig.AudioEncoding.LINEAR16,

こちらを参考にして解決しました(_ _)

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?