å®ã¯æ¨å¹´æ«ã«ãGoogle Homeãè¡åè²·ããã¾ããã
å§ãã¯ããªããè²ã 使ããªãããªã...ãã¨æã£ã¦ãã¾ããããè³¼å ¥ãã¦ãã°ããã¯ããããªã«ä½¿ç¨ãã¦ãã¾ããã§ããã
ããå æ¥Twitterã§ããã¤ã¯ãã½ããã®ã¨ãã³ã¸ã§ãªã¹ããå代ç°ã¾ã©ãï¼ã¡ãã¾ã©ï¼ããããããªãã¤ã¼ãããã¦ããã®ãè¦ã¾ãã¦ã
Google Home ã£ã¦å¥³æ§ã®å£°ããç¡ããã§ããã©ã
— ã¡ãã¾ã©ï¼ ã¢ã³ãã³ãããã (@chomado) 2018å¹´1æ18æ¥
ç§ããã¾ããç·ã®äººã«åã£ã¦ãããããã£ãã®ã§
ããã°ã©ãã³ã°ãã¾ããð
Node .jsã§æ¸ãã¾ããã
Voice Text API ã¨
MSã®ã¯ã©ã¦ããµã¼ãã¹ Azure Blob Storage 使ç¨
æ¸ããã³ã¼ã:https://t.co/K5KnzegMCy
ãã¢â(åç»(é³åºãã¦èãã¦ãï¼)) pic.twitter.com/Ha7vrbFpW1
ããã£ã±ããããããã¨ãã§ãããã ï¼é¢ç½ããï¼ãã£ã¦æãããã£ããï¼äºçªç ããããã¨ãï¼å®è¡ãã¦ã¿ã¾ãããï¼åã¯å¥³ã®åã大好ããªã®ã§ãç·ã®å£°ã«ã¯ããªãã§ããâ¦ï¼
â»ãã以éã®ä½æ¥ã¯ãWindowsã«ã¤ã³ã¹ãã¼ã«ããåæã§è¨è¼ãã¦ãã¾ãã
ï¼ï¼ã¤ã³ã¹ãã¼ã«
â node.jsã®ã¤ã³ã¹ãã¼ã«
Google Homeã«ããã¹ãããã«ã¯ãGoogle Home Notifierã¨ããjavascriptã®ããã°ã©ã ãå¿
è¦ã§ãã
ããã¦Google Home Notifierãåããã«ã¯ãnode.jsãå¿
è¦ã§ãã
ã¨ããããã§ãnode.jsã®ã¤ã³ã¹ãã¼ã«ããå§ãã¾ãã
ã¨ãã£ã¦ããnode.jsã®å
¬å¼ãµã¤ãï¼https://nodejs.org/ja/ï¼ããã¤ã³ã¹ãã¼ã©ã¼ããã¦ã³ãã¼ããã¦ãå®è¡ããã ãã§ãã®ã§ãé£ãããã¨ã¯ãªãã§ãã
â»ãæ¨å¥¨çãã¨ãææ°çããããã¾ããããæ¨å¥¨çããç¡é£ã
ã¤ã³ã¹ãã¼ã«å¾ãä¸è¨ã³ãã³ããã³ãã³ãããã³ããã§å ¥åãã¦ããã¼ã¸ã§ã³ã表示ãããã°OKãï¼ãããå«ããå ¨æé ã§ãã³ãã³ãããã³ããã¯ã管çè ã§å®è¡ããã¦ãã ãããï¼
> node --version
â node-gypã®ã¤ã³ã¹ãã¼ã«
node-gypã¯ãC++ãç¨ããæ¡å¼µæ©è½ãä½ãããã®ãã«ããã¼ã«çãªãã®ãããããGoogle Home Notifierã¤ã³ã¹ãã¼ã«ã«å¿
è¦ã«ãªãã¾ãã
ãããã¡ããã¨ãããªãã¨ãGoogle Home Notifierã®ã¤ã³ã¹ãã¼ã«ã§ã¨ã©ã¼ãåºã¾ããã®ã§ãè¦æ³¨æã§ããï¼ã¦ããåã¯ããã§1é±éè¿ãããã£ãâ¦ï¼
â»ããã¯node-gypã®githubã®ããã¥ã¡ã³ã(https://github.com/nodejs/node-gyp)ã«æ²¿ã£ã¦èª¬æããã¾ãã
ã¾ãã¤ã³ã¹ãã¼ã«ã¯ãã³ãã³ãããã³ããã§ä¸è¨ã³ãã³ããå ¥åããã°OKãï¼ããã¯åé¡ãªãã¨æãã¾ãï¼
> npm install -g node-gyp
ããã¦å
¬å¼ãµã¤ãã®ãOption 1ãã«ã
Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).
ï¼è¨³ï¼ãPowerShellãã³ãã³ãããã³ããã§'npm install --global --production windows-build-tools'ã¨ããã³ãã³ãã使ç¨ãã¦ãMicrosoft's windows-build-toolsãä»ãã¦å¿
è¦ãªãã¼ã«ãè¨å®æ
å ±ãã¤ã³ã¹ãã¼ã«ãã¦ãã ãããï¼ç®¡çè
権éã§å®è¡ãã¦ãï¼ï¼
ã¨ããéãã«ãã³ãã³ãããã³ãããã
> npm install --global --production windows-build-tools
ã¨å ¥åãã¦ããã®ä½æ¥ãå®äºããã¾ãã
â»ãªããOption 2ãã®æé ã¯ãå¿ è¦ãªãã¼ã«ãè¨å®æ å ±ããèªåã§ã¤ã³ã¹ãã¼ã«ããæ¹æ³ã§ãããOption 1ãã®æé ã¯ããããã¹ã¦ä¸è¨ã³ãã³ãä¸çºã§è¡ããã®ã§ããOption 1ãã®æé ã®ã»ãã楽ã§ããï¼å®æ½ããã®ã¯ããããä¸æ¹ã§ããï¼
æå¾ã«ã
If node-gyp is called by way of npm and you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:
ï¼è¨³ï¼node-gypãnpmçµç±ã§å®è¡ããå ´åã§ãpythonã®è¤æ°ãã¼ã¸ã§ã³ãã¤ã³ã¹ãã¼ã«ããã¦ããå ´åãï¼ä¸è¨ã³ãã³ãã®ããã«ï¼npmã®'python'ã³ã³ãã£ã°ã®å¤ãé©åãªå¤ã«ãã¦ãã ãããï¼
> npm config set python /path/to/executable/python2.7
ã¨ããã®ã§ããã®éãã«è¨å®ãã¾ããï¼ãªããnode-gypã¯python3.xã§ã¯åä½ãã¾ããããOption1ã®æé ãå®æ½ããã°ãå¥é2.xãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãã®ã§ãåé¡ãªãã¯ãã§ããï¼
â»ãªããå
¬å¼ããã¥ã¡ã³ãã«
If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:
ï¼è¨³ï¼ããè¤æ°ãã¼ã¸ã§ã³ã®pythonãã¤ã³ã¹ãã¼ã«ããã¦ããå ´åãnode-gypã«ä¸è¨ã³ãã³ãã§node-gypã§ä½¿ç¨ãããã¼ã¸ã§ã³ãè¨å®ãã¦ãã ããï¼
> node-gyp --python /path/to/python2.7
ã¨ããã¾ãããåãå®æ½ããéã¯ãã--pythonãªãã·ã§ã³ãªãã¦ãªãããã¨è¨ãããããã¯å®è¡ã§ãã¾ããã§ããã
次ã«ä½¿ç¨æ¹æ³ã§ããã
To compile your native addon, first go to its root directory:
ï¼è¨³ï¼ããªãã®ç°å¢ã®ã¢ããªã³ãã³ã³ãã¤ã«ããããã«ãã¾ãåãã«ï¼ããã¸ã§ã¯ãã®ï¼ã«ã¼ããã©ã«ãã«ç§»åãã¦ãã ãããï¼
> cd my_node_addon
ã¨ããã®ã§ãã¾ãã¯ã³ãã³ãããã³ããã®'cd'ã³ãã³ãã§ã*.jsãã¡ã¤ã«ãä½æãããã©ã«ãã«ç§»åãã¾ãã
次ã«ã
The next step is to generate the appropriate project build files for the current platform. Use configure for that:
ï¼è¨³ï¼æ¬¡ã«ããã©ãããã©ã¼ã æ¯ã«é©åãªããã¸ã§ã¯ãã®ãã«ããã¡ã¤ã«ãä½æãã¾ãã次ã®'configure'ã³ãã³ãã使ç¨ãã¾ããï¼
> node-gyp configure
Auto-detection fails for Visual C++ Build Tools 2015, so --msvs_version=2015 needs to be added (not needed when run by npm as configured above):
ï¼è¨³ï¼VC++ãã«ããã¼ã«ãèªåæ¤åºãã§ããªãã£ãå ´åã'--msvs_version=2015'ã¨ãããªãã·ã§ã³ãä»ãã¦ãã ãããï¼ä¸ã®ã³ãã³ãã§ãã¾ãããã°ä¸è¦ã§ãï¼ï¼
> node-gyp configure --msvs_version=2015
ã¨ããéãã'node-gyp configure'ã³ãã³ããå®è¡ãã¾ããããã§ãVC++ãã«ããã¼ã«ããªããã¨ããæ¨ã®ã¨ã©ã¼ã表示ãããããä¸ã®'node-gyp configure --msvs_version=2015'ã³ãã³ããå®æ½ããã°OKã§ãã
ãªãã
Note: The configure step looks for the binding.gyp file in the current directory to process. See below for instructions on creating the binding.gyp file.
Now you will have either a Makefile (on Unix platforms) or a vcxproj file (on Windows) in the build/ directory. Next invoke the build command:
ï¼è¨³ï¼'configure'ã³ãã³ãã¯'binding.gyp'ã¨ãããã¡ã¤ã«ãã«ã¬ã³ããã©ã«ãå
ããæ¤ç´¢ãã¾ãã'binding.gyp'ãã¡ã¤ã«ãä½æããã«ã¯ããbuildããã©ã«ãå
ã«'vcxproj'ãã¡ã¤ã«ãããã¨æãã®ã§ï¼Unixã§ã¯'Makefile'ãã¡ã¤ã«ï¼ãä¸è¨ã®ânode-gyp buildâã³ãã³ããå®è¡ãã¦ãã ãããï¼
> node-gyp build
ã¨ããè¨è¼ãããã®ã§ããããbinding.gypããªããã¨ãããæ¨ã®ã¨ã©ã¼ã表示ããããã'node-gyp build'ã³ãã³ããä¸åº¦å®è¡ãã¦ãããå度'configure'ã³ãã³ããå®è¡ããã°ããã¨æãã¾ãã
â Google-Home-Notifierã®ã¤ã³ã¹ãã¼ã«
ã§ãããããã¡ã¤ã³ã®Google-Home-Notifierã®ã¤ã³ã¹ãã¼ã«ã§ãã
ã¨ãã£ã¦ãããèªä½ã¯åç´ã§ãä¸è¨ã³ãã³ããå®è¡ããã ãã§ãã
> npm install google-home-notifier
â»ããã§ãdns_sd.hããã¡ã¤ã«ããªããã¨ããã¨ã©ã¼ã表示ãããå ´åãå ã«ä¸è¨ãBonjour SDK for Windowsã®ã¤ã³ã¹ãã¼ã«ããå®è¡ãã¦ãããå度ä¸è¨ã³ãã³ããå®è¡ãã¾ããï¼ã¨ã©ã¼ãåºãå ´åã大éã«åºãã¯ãã§ãï¼
â Bonjour SDK for Windowsã®ã¤ã³ã¹ãã¼ã«
ãdns_sd.hããã¡ã¤ã«ããªãã¨ããã¨ã©ã¼ã¯ããBonjour SDK for Windowsããã¤ã³ã¹ãã¼ã«ãããã¨ã§è§£æ±ºã§ããã®ã§ããããã¤ã³ã¹ãã¼ã«ãã¾ãã
ããã¯Apple Developerã«ããã®ã§ããããããã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã©ãå®è¡ããã°OKã§ãã
- ãã¦ã³ãã¼ãã«ã¯ãApple IDã§ã®ãµã¤ã³ã¤ã³ãå¿ è¦ã§ãã
- ã¤ã³ã¹ãã¼ã©èªä½ã¯ãç¹ã«è¨å®é ç®ã¯ãªãã§ããï¼ã¤ã³ã¹ãã¼ã«å ç¨åº¦ï¼
- ã¤ã³ã¹ãã¼ã«å®äºå¾ããã³ã³ããã¼ã«ããã«ããããç°å¢å¤æ°ã®ç·¨éããéãããã¦ã¼ã¶ã¼ç°å¢å¤æ°ãã«ãBONJOUR_SDK_HOMEãã追å ãã¦ãã ãããï¼å¤ã¯ãC:\Program Files\Bonjour SDKï¼ã
- ãã®ä½æ¥ãå®è¡ããå ´åãã³ãã³ãããã³ããã®åèµ·åãå¿ è¦ã®ããã§ãã
ãåèãµã¤ãã
ã»http://kghr.blog.fc2.com/blog-entry-118.html
ã»http://blog.livedoor.jp/sce_info3-craft/archives/9706909.html
ï¼ï¼ããã°ã©ãã³ã°ï¼ããããï¼
ã§ãå®éã®ããã°ã©ã ã§ãããå
¬å¼ãµã¤ã(https://github.com/noelportugal/google-home-notifier)ã®ã½ã¼ã¹ããã®ã¾ã¾ã³ããã§å¤§ä¸å¤«ãã¨æãã¾ãã
ã§ãè±èªãªã®ã§ã試ãã«ä¸è¨ãåèãµã¤ããå
ã®ãµã³ãã«ã½ã¼ã¹ããsample.jsãã¨ãããååã§ãã¡ã¤ã«ã«ä¿åãã¦ãä¸è¨ã³ãã³ãã§å®æ½ããã¦ã¿ã¾ãã
â»ã³ã¼ãèªä½ã¯é常ã«çãã§ãããç¹ã«åé¡ãªãåä½ããã¨æãã¾ããï¼åããããã¯ã¼ã¯ã«Google Homeãããäºãåæããªãæåã³ã¼ãããUTF-8ãã«ããå¿ è¦ãããã®ã§ãããã ãã¯æ³¨æãï¼
> node sample.js
var googlehome = require('google-home-notifier'); var language = 'ja'; // ããã«æ¥æ¬èªã表ã ja ãè¨å® // ãããã¯ã¼ã¯å ããGoogle Homeãè¦ã¤ãã¦ããã googlehome.device('Google Home', language); // ãã Google Home ã®IPã¢ãã¬ã¹ãæå®ãããªãã以ä¸ã®ã¹ã¯ãªããã«ç½®ãæãã // googlehome.ip('xxx.xxx.xxx.xxx', language); googlehome.notify('ããã«ã¡ã¯', function(res) { console.log(res); });
OKãåé¡ãªãã§ãã
â ç¶ãã¦ããã¹ããã
æå¾ã«ãç¶ãã¦ããã¹ããããã§ããããã¶ãæåã«ä¸è¨ã®ãããªããã°ã©ã ãæãã¤ããã¨æãã¾ãã
// ãããã¯ã¼ã¯å ããGoogle Homeãè¦ã¤ãã¦ããã googlehome.device('Google Home', language); // ãã Google Home ã®IPã¢ãã¬ã¹ãæå®ãããªãã以ä¸ã®ã¹ã¯ãªããã«ç½®ãæãã // googlehome.ip('xxx.xxx.xxx.xxx', language); googlehome.notify('ããã«ã¡ã¯', function(res) { console.log(res); }); googlehome.notify('ããã°ãã¯', function(res) { console.log(res); });
makeSpeak('ããã«ã¡ã¯'); makeSpeak('ããã°ãã¯'); function makeSpeak(sentence) { // ãããã¯ã¼ã¯å ããGoogle Homeãè¦ã¤ãã¦ããã googlehome.device('Google Home', language); // ãã Google Home ã®IPã¢ãã¬ã¹ãæå®ãããªãã以ä¸ã®ã¹ã¯ãªããã«ç½®ãæãã // googlehome.ip('xxx.xxx.xxx.xxx', language); googlehome.notify(sentence, function(res) { console.log(res); }); }
ããæ®å¿µãªãããããã¯ã©ã¡ããã¨ã©ã¼ã«ãªãã¾ããï¼ä¸è¨ã®ãããªã¨ã©ã¼ãåºãã¨æãã¾ããï¼
Error: mdns service already started
at Browser.start (c:\dev\js\google_home\node_modules\mdns\lib\mdns_service.js:30:11)
at Object.notify (c:\dev\js\google_home\node_modules\google-home-notifier\google-home-notifier.js:28:13)
at Timeout.makeSpeak [as _onTimeout] (c:\dev\js\google_home\google_home.js:37:16)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)
ã¨ãã£ã¦ã1è¡ç®ã«æãã£ãããmdns service already startedãã¨ããéããè¦ã¯æåã®å½ä»¤ããã§ã«å®æ½ä¸ãªã®ã§ã次ã®å½ä»¤ãå®è¡ã§ããªããã¨ããã ãã§ãã
ãªã®ã§ãä¾ãã°ä¸è¨ã®ããã«ãåã®å½ä»¤ãçµäºãã¦ãã次ã®å½ä»¤ãå®è¡ããããã«ããã°åé¡ãªãã§ããï¼ã¿ã¹ã¯ãã¥ã¼ã«è¿½å ããã¨ãããã£ã¨ããæ¹æ³ã¯ããã¨æãã¾ãããããã§ã¯ããã¯ç½®ãã¨ãã¾ãï¼
// åã®makeSpeak()ã®çµäºãå¾ ã¤ããã«setInterval()ãããã var count = 0; var val = setInterval(makeSpeak, 7500); function makeSpeak() { // Google Home Notifierã®è¨å® var googlehome = require('google-home-notifier'); var language = 'ja'; // ããã«æ¥æ¬èªã表ã ja ãè¨å® var sentence = ''; switch(count) { // ããã¹ãããå 容 case 0: sentence = 'ããããã'; break; case 1: sentence = 'ããèãã¦ããã'; break; case 2: sentence = 'ããã¾ãã許ãã¦ãã ãããä½ã§ããã¾ããã'; break; default: } count++; // ãããã¯ã¼ã¯å ããGoogle Homeãè¦ã¤ãã¦ããã googlehome.device('Google Home', language); // ãã Google Home ã®IPã¢ãã¬ã¹ãæå®ãããªãã以ä¸ã®ã¹ã¯ãªããã«ç½®ãæã // googlehome.ip('xxx.xxx.xxx.xxx', language); // å®éã«ããã¹ããã googlehome.notify(sentence, function(res) { console.log(res); }); // å ¨é¨ããã¹ã£ããçµäºã if(count > 2) { clearInterval(val); } }
â»ãªããä¸è¨ããã°ã©ã ãå®éã«å®è¡ããåç»ããä¸è¨ã«ãªãã¾ã(æãã¬ã¯ãåå¼ãã)
ã¡ãã¾ã©ããã®Google-Home-notifierã®ãã¤ã¼ãè¦ã¦ããããï¼ãã¨æã£ã¦ããã¯ã1é±é以ä¸ããã£ã¨Google Homeã«åããããã¨ãã§ããï¼é·ãã£ã...
— ãããã¼ (@makky12) 2018å¹´1æ27æ¥
â»ãªããè¨èã¯èª°ã§ãç¥ã£ã¦ãããªãã¿ã®è¨èãé¸ãã ã¤ããã§ãã pic.twitter.com/QPF7vzsJv8
ããã¼ãè¦å´ãã¾ãããã
ã§ãããã§ãGoogle Homeã®ä½¿ç¨å¹
ãåºããã¾ããã
ããããã¯ãGoogle Homeã©ãã©ã使ãããã¨æãã¾ãã
â¦ã¦ããæãªããé·ãæç« ã ãªãã