raspberry piでgoogle-homeを喋らせる

raspberry piでgoogle-homeを喋らせる

はじめに

前回までにラズパイの初期設定と、使用するデバイスのIP固定を行いました。
今回は、いよいよgoogle-home-notifierを使ってgooglehomeを喋らせます。

使用したコード

test.js

const googlehome = require('google-home-notifier')
const language = 'ja';

googlehome.device('Google-Home', language); 
googlehome.ip("192.168.xx.xx")  //googlehomeに固定したIPアドレス

googlehome.notify('こんにちは。私はグーグルホームです。', function(res) {
  console.log(res);
});

このページをほぼまるパクリでひとまずテストを行います。
コードの保存場所はどこでも構いません。

コマンドラインで

$ node test.js

と打ち込むと

*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
Error: get key failed from google
    at /home/pi/node_modules/google-tts-api/lib/key.js:27:13
    at process._tickCallback (internal/process/next_tick.js:68:7)

おやおやです。

WARNINGはひとまず無視するとして、グーグルからキーを取得できなかったとエラーを吐いています。

エラー対応

この後、いろいろいじった結果うまくいきましたが、なにをいじったのがよかったのかよくわかりませんでした。

実施したことは

です。
いずれも変更して問題になることはなさそうなので、すべて対応してしまっても良いと思います。

googleAPIの変更があるたびに上記のファイルは適宜設定の変更が必要になりそうです。
急にgooglehomeが喋らなくなったらこの辺りを疑ってみると良さそうです。