#やりたいこと
MESHで気軽にTTS(Text to Speech)を使えるようにしたい
#実行結果
動きタグを振るとGoogle Home Miniが入力したテキストをしゃべります。
動画のリンク:https://youtu.be/uFISjYJPvVQ
#必要なもの
- MESHアプリ対応スマートフォン
- MESHタグ
- MESH SDKのアカウント
- Raspberry Piと(設定に必要なキーボード,SDカードなど)
- Wifi環境
- Google Home (Mini)
###Google Home MiniとRaspberry Piの設定
下記のリンクを参考にして設定してください。
・GitHub - noelportugal/google-home-notifier
・Google Homeで時報を知らせる
・Twitterの通知をGoogle Homeに教えてもらう
###MESH SDKのカスタムタグの設定
PC等のブラウザでMESH SDKを開き、新しいタグを作り下記のjsonコードをインポートしてください。その後、スマートフォン側のアプリにカスタムタグを追加してください。
{"formatVersion":"1.0","tagData":{"name":"GoogleHomeSpeak","icon":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCABgAGADAREAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdh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70aS3t4J7/Q59f8M3lzdjwfpelX2uaP4a1Nr74k6j4j8Z/FPxDH4k8IgH7FUAFABQAUAFABQAUAFAHzH+194G/aM+JPwK8U+Cv2XPiR4W+FPxT1+Wx09PF/iiLWYRa+GLmR4PElr4f8Q6Da6tqXgzxNcWMoOl+LLXw74gvdOWK5t9Ig0HXL3S/GfhgA/HP4bf8ABAbQdV1efxh+05+0p428f+IvEdk+t+K7D4f6Xb6PfyfEHVr221PX9RvviX47n8aap430y4updYjuL+98EeE/EGuXN3Brl1caXOlzptwAftR8Cf2Vv2eP2ZtKfSvgb8JfCXw/E9vNaX2s2FpPqfi/V7OfUZtV+xa7451+41bxnr9lb3s7yWFnrWvX9tpsSwWmnxWtpbW0EQB9AUAFABQAUAFABQAUAFABQAUAFABQAUAFABQAUAFABQB//9k=","description":"","functions":[{"id":"function_0","name":"言葉を話す","connector":{"inputs":[{"label":""}],"outputs":[{"label":""}]},"properties":[{"name":"text","referenceName":"speakText","type":"string","defaultValue":"ここに入力してください"},{"name":"address","referenceName":"ipAddress","type":"string","defaultValue":"address"}],"extension":{"initialize":"","receive":"","execute":"var endPointURL = \"https://\" + properties.ipAddress + \".ngrok.io/google-home-notifier\";\n\najax ({\n url : endPointURL,\n type : 'post',\n headers: {'Content-Type': 'application/x-www-form-urlencoded'},\n timeout : 5000,\n\tdata:{text:properties.speakText},\n success : function ( contents ) {\n\t\tlog('trigger success');\n callbackSuccess( {\n resultType : 'continue'\n } );_\n },\n error : function ( request, errorMessage ) {\n log('trigger : Network error');\n\t\tlog(endPointURL);\n\t\tlog('trigger : ' + errorMessage);\n callbackSuccess( {\n resultType : 'continue'\n } );\n }\n});\n \nreturn {\n resultType : 'pause'\n};","result":"return {\n resultType : \"continue\"\n}\n"}}]}}
####実行方法
スマートフォンでアプリを立ち上げて、トリガーとなるタグと追加したカスタムタグをつなげてください。
その後、下記の画像のようにtextの部分にしゃべらせたい言葉を入力し、addressの部分にRaspberry Pi側で実行中のサービスでxxxxxxxと表示されている部分を入力してください。
curl -X POST -d "text=Hello Google Home" https://xxxxxxx.ngrok.io/google-home-notifier
あとはトリガーが実行したら、Google Homeが入力されたテキストをしゃべります。
#感想
レスポンスもよく3-5秒後に喋ってくれるので、ラピッドプロトタイピングで音声フィードバックを検証するのに便利だと思いました。個人的には、addressのxxxxxxの生成される乱英数字を固定したかったのですが、ngrokのサブドメイン固定が月額で有料だったので諦めました。笑