Skip to content

Instantly share code, notes, and snippets.

@ftkro
Last active August 29, 2015 14:04
Show Gist options
  • Save ftkro/a976be56a113c035b4d3 to your computer and use it in GitHub Desktop.
Save ftkro/a976be56a113c035b4d3 to your computer and use it in GitHub Desktop.
weathertalk
#!/bin/sh
date +"%Y年%m月%d日 %I時%M分現在の天気予報をお伝えします。" | open_jtalk -x /var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/mei/mei_normal.htsvoice -ow /tmp/announce.wav
wget 'http://weather.livedoor.com/forecast/webservice/json/v1?city=130010' -O- -q | jq -M -c '.description .text' | sed 's/\"//g' - | sed 's/\\n//g' - | sed 's/ //g' - | sed 's/寒気/かんき/g' - | sed 's/所々/ところどころ/g' - | sed 's/日中/にっちゅう/g' - | cut -c 1-804 | open_jtalk -x /var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/mei/mei_normal.htsvoice -ow /tmp/weather1.wav>/dev/null 2>&1
WORD=`wget 'http://weather.livedoor.com/forecast/webservice/json/v1?city=130010' -O- -q | jq -M -c '.description .text' | sed 's/\"//g' - | sed 's/\\n//g' - | sed 's/ //g' - | sed 's/寒気/かんき/g' - | sed 's/所々/ところどころ/g' - | sed 's/日中/にっちゅう/g' -| wc -c`
if `test $WORD -le 804` ; then
echo 'Noting for Todo'>/dev/null 2>&1
else
wget 'http://weather.livedoor.com/forecast/webservice/json/v1?city=130010' -O- -q | jq -M -c '.description .text' | sed 's/\"//g' - | sed 's/\\n//g' - | sed 's/ //g' - | sed 's/寒気/かんき/g' - | sed 's/所々/ところどころ/g' - | sed 's/日中/にっちゅう/g' - | cut -c 805-1600 | open_jtalk -x /var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/mei/mei_normal.htsvoice -ow /tmp/weather2.wav>/dev/null 2>&1
fi
echo '以上、お伝えしました。ご利用ありがとうございました。' | open_jtalk -x /var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/mei/mei_normal.htsvoice -ow /tmp/end.wav>/dev/null 2>&1
if `test $WORD -le 804` ; then
mv /tmp/weather1.wav /tmp/weather3.wav
else
sox /tmp/weather1.wav /tmp/weather2.wav /tmp/weather3.wav
fi
sox /tmp/announce.wav /tmp/weather3.wav /tmp/weather4.wav
sox /tmp/weather4.wav /tmp/end.wav /tmp/weather5.wav
sox /var/lib/asterisk/sounds/ja/callup.wav /tmp/weather5.wav /tmp/weather6.wav
sox /tmp/weather6.wav -r 8000 /tmp/weather7.wav>/dev/null 2>&1
sox /tmp/weather7.wav /tmp/weather.ul>/dev/null 2>&1
sox /tmp/weather7.wav /tmp/weather.gsm>/dev/null 2>&1
mv /tmp/weather.gsm /var/lib/asterisk/sounds/ja/
mv /tmp/weather.ul /var/lib/asterisk/sounds/ja/weather.ulaw
rm /tmp/announce.wav /tmp/weather3.wav /tmp/weather4.wav /tmp/weather5.wav /tmp/weather6.wav /tmp/weather7.wav /tmp/end.wav
if `test $WORD -le 804` ; then
echo 'Noting to do' >/dev/null 2>&1
else
rm /tmp/weather1.wav /tmp/weather2.wav
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment