SPEAKVOL of 0 leaves the volume setting untouched

This commit is contained in:
Alex 2020-02-03 21:58:45 +01:00
parent b41e2ed0bd
commit b23043f58e
2 changed files with 17 additions and 10 deletions

View File

@ -49,6 +49,7 @@
# 2019-12-30: v0.15 re-worked the volume setting for TTS commands # 2019-12-30: v0.15 re-worked the volume setting for TTS commands
# 2020-01-03: v0.15a introduce some proper "get_volume" # 2020-01-03: v0.15a introduce some proper "get_volume"
# 2020-01-08: v0.15b cleaned merge errors # 2020-01-08: v0.15b cleaned merge errors
# 2020-02-03: v0.15c SPEAKVOL of 0 leaves the volume setting untouched
# #
### ###
# #
@ -97,7 +98,7 @@ SET_OATHTOOL='/usr/bin/oathtool'
# tmp path # tmp path
SET_TMP="/tmp" SET_TMP="/tmp"
# Volume for speak commands # Volume for speak commands (a SPEAKVOL of 0 leaves the volume settings untouched)
SET_SPEAKVOL="30" SET_SPEAKVOL="30"
# if no current playing volume can be determined, fall back to normal volume # if no current playing volume can be determined, fall back to normal volume
SET_NORMALVOL="10" SET_NORMALVOL="10"
@ -392,9 +393,10 @@ case "$COMMAND" in
fi fi
;; ;;
speak:*) speak:*)
SEQUENCECMD='Alexa.Speak'
TTS=$(echo ${COMMAND##*:} | sed -r 's/["\\]/ /g') TTS=$(echo ${COMMAND##*:} | sed -r 's/["\\]/ /g')
TTS=',\"textToSpeak\":\"'${TTS}'\"' TTS=',\"textToSpeak\":\"'${TTS}'\"'
SEQUENCECMD='Alexa.Speak'
SEQUENCEVAL=$TTS
;; ;;
automation:*) automation:*)
SEQUENCECMD='automation' SEQUENCECMD='automation'
@ -617,12 +619,14 @@ if [ -n "${SEQUENCECMD}" ] ; then
ALEXACMD='{"behaviorId":"'${AUTOMATION}'","sequenceJson":"'${SEQUENCE}'","status":"ENABLED"}' ALEXACMD='{"behaviorId":"'${AUTOMATION}'","sequenceJson":"'${SEQUENCE}'","status":"ENABLED"}'
else else
# the speak command is treated differently in that the wolume gets set to $SPEAKVOL if echo $COMMAND | grep -q -E "weather|traffic|flashbriefing|goodmorning|singasong|tellstory|speak" ; then
if [ -n "${TTS}" ] ; then
if [ "${DEVICEFAMILY}" = "WHA" ] ; then if [ "${DEVICEFAMILY}" = "WHA" ] ; then
echo "Skipping unsupported command: ${COMMAND} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} family:${DEVICEFAMILY}" echo "Skipping unsupported command: ${COMMAND} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} family:${DEVICEFAMILY}"
return return
fi fi
fi
# the speak command is treated differently if $SPEAKVOL is > 0
if [ -n "${TTS}" -a $SPEAKVOL -gt 0 ] ; then
SVOL=$SPEAKVOL SVOL=$SPEAKVOL
# Not using arrays here in order to be compatible with non-Bash # Not using arrays here in order to be compatible with non-Bash

View File

@ -3,7 +3,7 @@
# Amazon Alexa Remote Control (PLAIN shell) # Amazon Alexa Remote Control (PLAIN shell)
# alex(at)loetzimmer.de # alex(at)loetzimmer.de
# #
# 2020-01-08: v0.15b (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html) # 2020-02-03: v0.15c (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html)
# #
### ###
# #
@ -51,7 +51,7 @@ SET_OATHTOOL='/usr/bin/oathtool'
# tmp path # tmp path
SET_TMP="/tmp" SET_TMP="/tmp"
# Volume for speak commands # Volume for speak commands (a SPEAKVOL of 0 leaves the volume settings untouched)
SET_SPEAKVOL="30" SET_SPEAKVOL="30"
# if no current playing volume can be determined, fall back to normal volume # if no current playing volume can be determined, fall back to normal volume
SET_NORMALVOL="10" SET_NORMALVOL="10"
@ -321,9 +321,10 @@ case "$COMMAND" in
fi fi
;; ;;
speak:*) speak:*)
SEQUENCECMD='Alexa.Speak'
TTS=$(echo ${COMMAND##*:} | sed -r 's/["\\]/ /g') TTS=$(echo ${COMMAND##*:} | sed -r 's/["\\]/ /g')
TTS=",\\\"textToSpeak\\\":\\\"${TTS}\\\"" TTS=',\"textToSpeak\":\"'${TTS}'\"'
SEQUENCECMD='Alexa.Speak'
SEQUENCEVAL=$TTS
;; ;;
weather) weather)
SEQUENCECMD='Alexa.Weather.Play' SEQUENCECMD='Alexa.Weather.Play'
@ -619,12 +620,14 @@ set_var()
run_cmd() run_cmd()
{ {
if [ -n "${SEQUENCECMD}" ] ; then if [ -n "${SEQUENCECMD}" ] ; then
# the speak command is treated differently in that the wolume gets set to $SPEAKVOL if echo $COMMAND | grep -q -E "weather|traffic|flashbriefing|goodmorning|singasong|tellstory|speak" ; then
if [ -n "${TTS}" ] ; then
if [ "${DEVICEFAMILY}" = "WHA" ] ; then if [ "${DEVICEFAMILY}" = "WHA" ] ; then
echo "Skipping unsupported command: ${COMMAND} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} family:${DEVICEFAMILY}" echo "Skipping unsupported command: ${COMMAND} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} family:${DEVICEFAMILY}"
return return
fi fi
fi
# the speak command is treated differently if $SPEAKVOL > 0
if [ -n "${TTS}" -a $SPEAKVOL -gt 0 ] ; then
SVOL=$SPEAKVOL SVOL=$SPEAKVOL
# Not using arrays here in order to be compatible with non-Bash # Not using arrays here in order to be compatible with non-Bash