-
-
Save kaz-mac/14afbedc1036f3bc9e52d7925968c142 to your computer and use it in GitHub Desktop.
M5Stack Module-LLMでVOICEVOXを使ってテキストから音声を再生するスクリプト
This file contains hidden or 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
| #!/bin/bash | |
| in_file=$1 | |
| ## 設定 | |
| speaker=1 # ずんだもん | |
| #speaker=2 # 四国めたん | |
| volume=0.1 | |
| if [ ! -e "${in_file}" ] ; then | |
| echo "input file not found" | |
| exit 1 | |
| fi | |
| echo -n "Generate audio query..." | |
| curl -sGX POST \ | |
| "http://127.0.0.1:50021/audio_query" \ | |
| --data-urlencode "text@${in_file}" \ | |
| --data "speaker=${speaker}" \ | |
| --data "enable_katakana_english=true" \ | |
| -H "Accept: application/json" \ | |
| --output /tmp/vv_query.json | |
| echo done | |
| ls -l /tmp/vv_query.json | |
| jq ".outputSamplingRate=16000 | .outputStereo=true | .volumeScale=${volume}" \ | |
| /tmp/vv_query.json > /tmp/vv_query.json.tmp \ | |
| && mv /tmp/vv_query.json.tmp /tmp/vv_query.json | |
| echo -n "Synthesis..." | |
| curl -sX POST \ | |
| "http://127.0.0.1:50021/synthesis?speaker=${speaker}&enable_interrogative_upspeak=true" \ | |
| -H "Accept: audio/wav" \ | |
| -H "Content-Type: application/json" \ | |
| --data @/tmp/vv_query.json \ | |
| --output /tmp/vv_voice.wav | |
| echo done | |
| ls -l /tmp/vv_voice.wav | |
| echo -n "Play..." | |
| #aplay -D plughw:0,1 /tmp/vv_voice.wav | |
| tinyplay -D0 -d1 /tmp/vv_voice.wav | |
| echo done | |
| rm -f /tmp/vv_query.json /tmp/vv_voice.wav |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment