Last active
January 19, 2016 07:45
-
-
Save yusukeyamatani/4d642c782f7e0c1931f9 to your computer and use it in GitHub Desktop.
簡単にできる!音声認識と音声合成を使ってRaspberrypiと会話 ref: http://qiita.com/kinpira/items/75513eaab6eed19da9a3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ lsusb | |
Bus 001 Device 005: ID 056e:4008 Elecom Co., Ltd | |
Bus 001 Device 004: ID 0d8c:0134 C-Media Electronics, Inc. | |
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter | |
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. | |
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat /proc/asound/modules | |
0 snd_bcm2835 | |
1 snd_usb_audio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install python-pyaudio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python pyaudio_test.py | |
Please input recoding time>>> 3 | |
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline | |
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline | |
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave | |
Cannot connect to server socket err = No such file or directory | |
Cannot connect to server request channel | |
jack server is not running or cannot be started | |
ここでマイク入力を行います。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ aplay -Dhw:1,0 mono.wav |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localpc ~ $ scp ~/Desktop/aquestalkpi-20130827.tgz user@host:/home/pi/ | |
aquestalkpi-20130827.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tar xvf aquestalkpi-20130827.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd aquestalkpi | |
$ ./AquesTalkPi "オンギャーオンギャー" | aplay -Dhw:1,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python dialogue_test.py | |
Please input recoding time>>>3 | |
~~snip~~ | |
元気ですか? ←マイクから入力した内容 | |
元気でちゅ ←Rasタソの回答 | |
$ python dialogue_test.py | |
Please input recoding time>>>3 | |
~~snip~~ | |
何歳ですか。←マイクから入力した内容 | |
ところで、気になるニュースがあるんだが、カルビーと阪急そばがコラボレーションして「関西だししょうゆポテトチップスそば・うどん」を期間限定で販売、関西だしの旨みと斬新な食感が味わえるそうでちゅ←Rasタソの回答 | |
$ python dialogue_test.py | |
Please input recoding time>>>3 | |
~~snip~~ | |
誕生おめでとう。←マイクから入力した内容 | |
楽しみに待ってるか? ←Rasタソの回答 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo cat /etc/modprobe.d/alsa-base.conf | |
options snd slots=snd_usb_audio,snd_bcm2835 | |
options snd_usb_audio index=0 | |
options snd_bcm2835 index=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat /proc/asound/modules | |
0 snd_usb_audio | |
1 snd_bcm2835 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ amixer sset Mic 50 | |
Simple mixer control 'Mic',0 | |
Capabilities: cvolume cvolume-joined cswitch cswitch-joined | |
Capture channels: Mono | |
Limits: Capture 0 - 62 | |
Mono: Capture 50 [81%] [16.59dB] [on] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ arecord -r 16000 -f S16_LE test.wav | |
録音中 WAVE 'test.wav' : Signed 16 bit Little Endian, レート 16000 Hz, モノラル | |
^C | |
シグナル 割り込み で中断... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ aplay -l | |
**** ハードウェアデバイス PLAYBACK のリスト **** | |
カード 1: ALSA [bcm2835 ALSA], デバイス 0: bcm2835 ALSA [bcm2835 ALSA] | |
サブデバイス: 8/8 | |
サブデバイス #0: subdevice #0 | |
サブデバイス #1: subdevice #1 | |
サブデバイス #2: subdevice #2 | |
サブデバイス #3: subdevice #3 | |
サブデバイス #4: subdevice #4 | |
サブデバイス #5: subdevice #5 | |
サブデバイス #6: subdevice #6 | |
サブデバイス #7: subdevice #7 | |
カード 1: ALSA [bcm2835 ALSA], デバイス 1: bcm2835 ALSA [bcm2835 IEC958/HDMI] | |
サブデバイス: 1/1 | |
サブデバイス #0: subdevice #0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ aplay -Dhw:1,0 test.wav | |
再生中 WAVE 'test.wav' : Signed 16 bit Little Endian, レート 16000 Hz, モノラル |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python | |
>>> import requests | |
>>> import json | |
>>> url = "https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY={}".format(APIKEY) | |
>>> payload = { | |
"utt": "こんにちは", | |
"context": "", | |
"nickname": "光", | |
"nickname_y": "ヒカリ", | |
"sex": "女", | |
"bloodtype": "B", | |
"birthdateY": "1997", | |
"birthdateM": "5", | |
"birthdateD": "30", | |
"age": "16", | |
"constellations": "双子座", | |
"place": "東京", | |
"mode": "dialog", | |
} | |
>>> r = requests.post(url, data=json.dumps(payload)) | |
>>> print r.json()['utt'] | |
こんちは |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python | |
>>> import requests | |
>>> path = '/home/pi/test.wav' | |
>>> url = "https://api.apigw.smt.docomo.ne.jp/amiVoice/v1/recognize?APIKEY={}".format(APIKEY) | |
>>>files = {"a": open(path, 'rb'), "v":"on"} | |
>>>r = requests.post(url, files=files) | |
>>> print r.json()['text'] | |
なんでやねん。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment