Skip to content

Instantly share code, notes, and snippets.

@kaz-mac
Last active July 6, 2025 01:02
Show Gist options
  • Select an option

  • Save kaz-mac/14afbedc1036f3bc9e52d7925968c142 to your computer and use it in GitHub Desktop.

Select an option

Save kaz-mac/14afbedc1036f3bc9e52d7925968c142 to your computer and use it in GitHub Desktop.
M5Stack Module-LLMでVOICEVOXを使ってテキストから音声を再生するスクリプト
#!/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