#出来た事
NAS上の音楽をAlexaから音声入力で操作、別のスピーカーで音楽を鳴らす。
簡単にできる事としては以下の通り
- 再生(mpc play)
- 停止(mpc stop)
- 次の曲を再生(mpc next)
- 前の曲を再生(mpc prev)
- 音量の指定(mpc volume)
#全体図
alexaのNode-RED Alexa Home Skill Bridgeを使ってラズベリーパイ上のMPDサーバーをMPCコマンドで操作する。ラズベリーパイには、NAS上の音楽リソースがおいているフォルダをマウントする。
ラズベリーパイからは、USB DACを使って別のスピーカーに接続し、そのスピーカーで音楽を再生する。
#ラズパイとNode-Red
以下の記事などを参考にセットアップ
Amazon Echoとラズパイで、音声で照明をon/offする
#mpdとmpc
以下の記事などを参考にセットアップ
[Rapberry Pi に USB DAC をつないでオーディオサーバーにする (接続編)]
(https://qiita.com/henri_t/items/33a514ae4ac0fda89ee0)
以下のJsonをNode-Redで読み込むとフローが作成されます
[{"id":"f503001b.95204","type":"exec","z":"4b16e69e.6f2308","command":"mpc play","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":633.0000038146973,"y":180.29999923706055,"wires":[[],[],[]]},{"id":"23a5391.93962c6","type":"switch","z":"4b16e69e.6f2308","name":"","property":"command","propertyType":"msg","rules":[{"t":"eq","v":"TurnOnRequest","vt":"str"},{"t":"eq","v":"TurnOffRequest","vt":"str"},{"t":"eq","v":"IncrementPercentageRequest","vt":"str"},{"t":"eq","v":"DecrementPercentageRequest","vt":"str"},{"t":"eq","v":"SetPercentageRequest","vt":"str"}],"checkall":"true","outputs":5,"x":390,"y":180,"wires":[["f503001b.95204"],["46ab8f67.8e599"],["9c02eead.a1221"],["72d54e3b.91397"],["8eef9581.cdbd08"]]},{"id":"46ab8f67.8e599","type":"exec","z":"4b16e69e.6f2308","command":"mpc stop","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":632.300048828125,"y":246.80000114440918,"wires":[[],[],[]]},{"id":"9c02eead.a1221","type":"exec","z":"4b16e69e.6f2308","command":"mpc next","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":633.2999877929688,"y":323.7999954223633,"wires":[[],[],[]]},{"id":"72d54e3b.91397","type":"exec","z":"4b16e69e.6f2308","command":"mpc prev","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":633.3000526428223,"y":399.80000495910645,"wires":[[],[],[]]},{"id":"8eef9581.cdbd08","type":"exec","z":"4b16e69e.6f2308","command":"mpc volume","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":643.2999877929688,"y":480.7999954223633,"wires":[[],[],[]]},{"id":"2963d1ea.3e11ae","type":"alexa-home","z":"4b16e69e.6f2308","conf":"","device":"","acknoledge":true,"name":"","topic":"","x":230,"y":180,"wires":[["23a5391.93962c6"]]}]
#あとがき
今のところ、曲の指定などはやっていません。mpcのコマンドを動かしているだけなので、やりようを変えれば色んなことが出来るかも...
ただ、曲の指定等は素直に他のmpdクライアントアプリ使った方が楽かもしれません
#参考にした記事など
Amazon Echoとラズパイで、音声で照明をon/offする
[Rapberry Pi に USB DAC をつないでオーディオサーバーにする (接続編)]
(https://qiita.com/henri_t/items/33a514ae4ac0fda89ee0)