その4:Google Homeでできるラズパイ不要でおしゃべり

スポンサーリンク

(あ)です。

「Google Homeにしゃべってもらう」の事実上のスタートラインに立った状況と理解しつつ、進めていきます。

nodejs等インストール

# apt-get install -y nodejs npm
# npm cache clean
# npm install n -g
# apt-get install -y curl
# n stable
# ln -sf /usr/local/bin/node /usr/bin/node
# node -v
v9.8.0
# npm -v
1.4.21

この辺りまでは、順調です。

なにやらエラーが!avahi-daemon,libnss-mdns,libavahi-compat-libdnssd-devが導入できてない?

次にmDNS関連をインストールします。

# apt install -y avahi-daemon libnss-mdns libavahi-compat-libdnssd-dev
...
Failed to read /proc/cmdline. Ignoring: Permission denied
...
Reloading system message bus config...Failed to open connection to "system" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

ん!なにやらエラーっぽいことがおきているメッセージが表示されています。

が、このときはよく分からないまま、続けてコマンドを入力しました。

google-home-notifierをインストール…できてない?

とうとうgoogle-home-notifierのインストールです。

npm install google-home-notifier

なにやらエラーが出ます…

make: *** [Release/obj.target/dns_sd_bindings/src/dns_sd.o] Error 1
make: Leaving directory '/root/node_modules/google-home-notifier/node_modules/mdns/build'
gyp ERR! build error 

ずらーっと出たあと、最終的に次の表示で止まりました。

npm ERR! not ok code 0

2回ほどリトライしましたが、それでも改善はしませんでした。

再度、前段でエラーになっていたモジュールをインストールし直しても、改善はせずです。

前に進んでみます

google-home-notifierに入っているexample.jsを見ながら、サーバ機能なしのハードコード文言をしゃべらせるべく、つぎのようなコードを書きました。(node ghnTest.js)

const googlehome = require('google-home-notifier');
const message = "hello world";
googlehome.device('living', 'ja');
googlehome.ip('192.168.xxx.yyy');  // Google HomeのIPアドレス
googlehome.accent('ja');
googlehome.notify(message, res => console.log(res));

実行してみます。

# node ghnTest.js

コンソールには次の表示です。

module.js:545
    throw err;

Error: Cannot find module '../build/Release/dns_sd_bindings'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:470:25)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/node_modules/mdns/lib/dns_sd.js:32:22)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)

どうやら、mdns/lib/dns_sd.jsあたりのロードに失敗しているようです。

先に、サービスやらデーモンやら起動する必要があるようです。

# service dbus start
# systemctl enable dbus

エラーです。

Failed to read /proc/cmdline. Ignoring: Permission denied
Synchronizing state for dbus.service with sysvinit using update-rc.d...
# service avahi-daemon restart
[....] Restarting Avahi mDNS/DNS-SD Daemon: avahi-daemonTimeout reached while wating for return value
Could not receive return value from daemon process.
[warn (warning).

ううむ、思うようには行きません。Windows10のUbuntuでは、このあたりすんなり行ったのですが…

Zzz…

コメント

タイトルとURLをコピーしました