From 7dfd6ab6d6c144046354db86248b9abc83a01c17 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 9 Feb 2020 20:53:03 +0100 Subject: [PATCH] added sound library --- README.md | 5 ++++- alexa_remote_control.sh | 13 ++++++++++--- alexa_remote_control_plain.sh | 15 ++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) mode change 100644 => 100755 README.md diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 6359c49..2ce6d8a --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ VOLMAXAGE - max. age in minutes before volume is re-read from API DEVICEVOLNAME - a list of device names with specific volume settings (space separated) DEVICEVOLSPEAK - a list of speak volume levels - matching the devices above DEVICEVOLNORMAL - a list of normal volume levels- matching the devices above +USE_ANNOUNCEMENT_FOR_SPEAK - Announcements can be made to multiple devices, while + regular SPEAK cannot but the announcement feature has + to be turned on for those devices. Also supports SSML! ``` You will very likely want to set the language to: ``` @@ -36,7 +39,7 @@ alexa-remote-control [-d |ALL] -e ',automation:'' + speak:'',automation:',sound:' -b : connect/disconnect/list bluetooth device -q : query queue -n : query notifications diff --git a/alexa_remote_control.sh b/alexa_remote_control.sh index fb09505..5f20795 100755 --- a/alexa_remote_control.sh +++ b/alexa_remote_control.sh @@ -52,6 +52,8 @@ # 2020-02-03: v0.15c SPEAKVOL of 0 leaves the volume setting untouched # 2020-02-09: v0.16 TTS to Multiroom groups via USE_ANNOUNCEMENT_FOR_SPEAK + SSML for TTS # (!!! requires Announcement feature to be enabled in each device !!!) +# 2020-02-09: v0.16a added sound library - only very few sounds are actually supported +# ( https://developer.amazon.com/en-US/docs/alexa/custom-skills/ask-soundlibrary.html ) # ### # @@ -179,7 +181,8 @@ usage() echo " -i | -p | -P | -S | -a | -m [device_1 .. device_X] | -lastalexa | -z | -l | -h" echo echo " -e : run command, additional SEQUENCECMDs:" - echo " weather,traffic,flashbriefing,goodmorning,singasong,tellstory,speak:'',automation:''" + echo " weather,traffic,flashbriefing,goodmorning,singasong,tellstory," + echo " speak:'',automation:'',sound:" echo " -b : connect/disconnect/list bluetooth device" echo " -q : query queue" echo " -n : query notifications" @@ -205,7 +208,7 @@ usage() while [ "$#" -gt 0 ] ; do case "$1" in --version) - echo "v0.16" + echo "v0.16a" exit 0 ;; -d) @@ -413,6 +416,10 @@ case "$COMMAND" in SEQUENCEVAL=$TTS fi ;; + sound:*) + SEQUENCECMD='Alexa.Sound' + SEQUENCEVAL=',\"soundStringId\":\"'${COMMAND##sound:}'\"' + ;; automation:*) SEQUENCECMD='automation' UTTERANCE=$(echo ${COMMAND##automation:} | sed -r 's/["\\]/ /g') @@ -635,7 +642,7 @@ if [ -n "${SEQUENCECMD}" ] ; then ALEXACMD='{"behaviorId":"'${AUTOMATION}'","sequenceJson":"'${SEQUENCE}'","status":"ENABLED"}' else # SequenceCommands are generally not supported on WHA devices - if echo $COMMAND | grep -q -E "weather|traffic|flashbriefing|goodmorning|singasong|tellstory" ; then + if echo $COMMAND | grep -q -E "weather|traffic|flashbriefing|goodmorning|singasong|tellstory|sound" ; then if [ "${DEVICEFAMILY}" = "WHA" ] ; then echo "Skipping unsupported command: ${COMMAND} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} family:${DEVICEFAMILY}" return diff --git a/alexa_remote_control_plain.sh b/alexa_remote_control_plain.sh index 00c6456..c2d5edd 100755 --- a/alexa_remote_control_plain.sh +++ b/alexa_remote_control_plain.sh @@ -3,7 +3,7 @@ # Amazon Alexa Remote Control (PLAIN shell) # alex(at)loetzimmer.de # -# 2020-02-03: v0.15c (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html) +# 2020-02-09: v0.16a (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html) # ### # @@ -52,7 +52,7 @@ SET_OATHTOOL='/usr/bin/oathtool' SET_TMP="/tmp" # Volume for speak commands (a SPEAKVOL of 0 leaves the volume settings untouched) -SET_SPEAKVOL="30" +SET_SPEAKVOL="0" # if no current playing volume can be determined, fall back to normal volume SET_NORMALVOL="10" @@ -120,7 +120,8 @@ usage() echo " -a | -m [device_1 .. device_X] | -lastalexa | -l | -h" echo echo " -e : run command, additional SEQUENCECMDs:" - echo " weather,traffic,flashbriefing,goodmorning,singasong,tellstory,speak:''" + echo " weather,traffic,flashbriefing,goodmorning,singasong,tellstory," + echo " speak:''sound:" echo " -b : connect/disconnect/list bluetooth device" echo " -q : query queue" echo " -n : query notifications" @@ -141,7 +142,7 @@ usage() while [ "$#" -gt 0 ] ; do case "$1" in --version) - echo "v0.15c" + echo "v0.16a" exit 0 ;; -d) @@ -326,6 +327,10 @@ case "$COMMAND" in SEQUENCECMD='Alexa.Speak' SEQUENCEVAL=$TTS ;; + sound:*) + SEQUENCECMD='Alexa.Sound' + SEQUENCEVAL=',\"soundStringId\":\"'${COMMAND##sound:}'\"' + ;; weather) SEQUENCECMD='Alexa.Weather.Play' ;; @@ -620,7 +625,7 @@ set_var() run_cmd() { if [ -n "${SEQUENCECMD}" ] ; then - if echo $COMMAND | grep -q -E "weather|traffic|flashbriefing|goodmorning|singasong|tellstory|speak" ; then + if echo $COMMAND | grep -q -E "weather|traffic|flashbriefing|goodmorning|singasong|tellstory|speak|sound" ; then if [ "${DEVICEFAMILY}" = "WHA" ] ; then echo "Skipping unsupported command: ${COMMAND} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} family:${DEVICEFAMILY}" return