2017年12月28日木曜日

Google Home:喋らせるぞ!!(日本語)

日本語を喋らせてみよう!!

喋り始めたので次は日本語に挑戦です。
引き続き、
「GoogleHomeスピーカーに外部からプッシュして自発的に話してもらいます」
を参照させてもらいました。ありがとうございます。

日本語を喋らせるには「example.js」を修正します。
  • 喋る内容が日本語であることを伝える
  • デバイスが日本語対応であることを伝える
ことが必要です。
pi@raspberrypi:~/google-home-notifier $ vi example.js

修正箇所をdiffしました。(前回の修正も含んでいます)
pi@raspberrypi:~/google-home-notifier $ cat example.js.diff
8,9c8,9
< var deviceName = 'Google Home';
< var ip = '192.168.1.20'; // default IP
---
> var deviceName = 'livingroom';
> var ip = '192.168.3.28'; // default IP
24c24
<   var language = 'pl'; // default language code
---
>   var language = 'ja'; // default language code
29c29,30
<   googlehome.ip(ip, language);
---
>   googlehome.device(deviceName, language);
>   googlehome.ip(ip);
65c66
<   var language = 'pl'; // default language code
---
>   var language = 'ja'; // default language code
70c71,72
<   googlehome.ip(ip, language);
---
>   googlehome.device(deviceName, language);
>   googlehome.ip(ip);

準備ができたので、サーバを起動して喋らせてみます。
まずは日本語です。
pi@raspberrypi:~/google-home-notifier $ curl -X POST -d "text=ハロー グーグルホーム" https://63f1c2c1.ngrok.io/google-home-notifier
{ text: 'ハロー グーグルホーム' }
Device notified
livingroom will say: ハロー グーグルホーム
やったね♪日本語喋った!!

次に、英語を喋らせてみます。
pi@raspberrypi:~/google-home-notifier $ curl -X POST -d "text=Hello Google Home"  https://63f1c2c1.ngrok.io/google-home-notifier
{ text: 'Hello Google Home' }
Device notified
livingroom will say: Hello Google Home
なんと。。。日本語的な英語だ。。。(@_@;)
カタカナで書いたのと変わらない。。。

平家物語の冒頭を喋らせてみました。
pi@raspberrypi:~/google-home-notifier $ curl -X POST -d "text=祇園精舎の鐘の声、諸行無常の響きあり。" https://63f1c2c1.ngrok.io/google-home-notifier
{ text: '祇園精舎の鐘の声、諸行無常の響きあり。' }
Device notified
livingroom will say: 祇園精舎の鐘の声、諸行無常の響きあり。
ちゃんと漢字も読めてるじゃん♪

ちょっとノロマで抑揚のない日本語ですね^^;
でも、ちゃ~~~んと喋りました。やったね!!
今日はここまで。

0 件のコメント:

コメントを投稿