From 7aaa9d683a8bd323e589bd1980ecea6711b581ba Mon Sep 17 00:00:00 2001 From: slowrunner Date: Sat, 14 Sep 2024 20:20:12 -0400 Subject: [PATCH] adjust volume adjusters --- plib/speak.py | 12 ++++++------ utils/set_vol_100_pct.sh | 2 +- utils/set_vol_40_pct.sh | 2 +- utils/set_vol_80_pct.sh | 2 +- utils/set_vol_normal.sh | 2 +- utils/set_vol_shout.sh | 4 ++++ utils/set_vol_very_very_low.sh | 4 ++-- 7 files changed, 16 insertions(+), 12 deletions(-) create mode 100755 utils/set_vol_shout.sh diff --git a/plib/speak.py b/plib/speak.py index 57f16a8..3af0047 100755 --- a/plib/speak.py +++ b/plib/speak.py @@ -79,7 +79,7 @@ def say_espeak(phrase,vol=100,anytime=False): subprocess.check_output(['espeak-ng -a'+str(vol)+' "%s"' % phrase], stderr=subprocess.STDOUT, shell=True) logger.info(phrase+spoken) -def say_piper(phrase,vol=100,anytime=False): +def say_piper(phrase,vol=75,anytime=False): phrase = phrase.replace("I'm","I m") phrase = phrase.replace("'","") @@ -97,7 +97,7 @@ def say_piper(phrase,vol=100,anytime=False): # subprocess.check_output(['espeak-ng -a'+str(vol)+' "%s"' % phrase], stderr=subprocess.STDOUT, shell=True) # subprocess.check_output(['echo "%s" | piper --model /home/pi/GoPi5Go/models/piper-tts/en_US-arctic-medium.onnx --output_raw | aplay -D plughw:2,0 -r 22050 -f S16_LE -t raw -' % phrase], stderr=subprocess.STDOUT, shell=True) # subprocess.check_output(['./piper.sh "%s"' % phrase], stderr=subprocess.STDOUT, shell=True) - cmd = "amixer -D pulse set Master {:d}%".format(int(vol/3)) + cmd = "amixer -D pulse set Master {:d}%".format(int(vol)) # print("cmd:",cmd) # subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) os.system(cmd) @@ -111,20 +111,20 @@ def say_piper(phrase,vol=100,anytime=False): logger.info(phrase+spoken) -def say(phrase,vol=200,anytime=False): +def say(phrase,vol=75,anytime=False): # say_espeak(phrase,vol,anytime) # vol = 50 for HP amplified spkr # vol = vol + 40 # adjust for flite # say_flite(phrase,vol,anytime) say_piper(phrase,vol,anytime) -def shout(phrase,vol=500,anytime=False): +def shout(phrase,vol=100,anytime=False): # say_espeak(phrase,vol,anytime) # vol = vol - 50 # adjust for flite # say_flite(phrase,vol,anytime) say_piper(phrase,vol,anytime) -def whisper(phrase,vol=40,anytime=False): +def whisper(phrase,vol=45,anytime=False): # say_espeak(phrase,vol,anytime) # vol = vol + 30 # adjust for flite # say_flite(phrase,vol,anytime=False) @@ -141,7 +141,7 @@ def main(): if ( len(sys.argv)>2 ): vol=int(sys.argv[2]) else: - vol=50 + vol=80 if ( len(sys.argv)>3 ): ignore= ( sys.argv[3] == "True" ) else: diff --git a/utils/set_vol_100_pct.sh b/utils/set_vol_100_pct.sh index 5b2d21c..3bbe19b 100755 --- a/utils/set_vol_100_pct.sh +++ b/utils/set_vol_100_pct.sh @@ -1,4 +1,4 @@ #!/bin/bash +~/GoPi5Go/plib/speak.py 'Volume set to 100 percent' 100 amixer -D pulse sset Master 100% -~/GoPi5Go/plib/speak.py 'Volume set to 100 percent' diff --git a/utils/set_vol_40_pct.sh b/utils/set_vol_40_pct.sh index bd06e1c..5ccc7ae 100755 --- a/utils/set_vol_40_pct.sh +++ b/utils/set_vol_40_pct.sh @@ -1,4 +1,4 @@ #!/bin/bash +~/GoPi5Go/plib/speak.py 'Volume set to 40 percent' 40 amixer -D pulse sset Master 40% -~/GoPi5Go/plib/speak.py 'Volume set to 40 percent' diff --git a/utils/set_vol_80_pct.sh b/utils/set_vol_80_pct.sh index 2232939..cba28e1 100755 --- a/utils/set_vol_80_pct.sh +++ b/utils/set_vol_80_pct.sh @@ -1,4 +1,4 @@ #!/bin/bash +~/GoPi5Go/plib/speak.py 'Volume set to 80 percent' 80 amixer -D pulse sset Master 80% -~/GoPi5Go/plib/speak.py 'Volume set to 80 percent' diff --git a/utils/set_vol_normal.sh b/utils/set_vol_normal.sh index 702d18d..89b9c8f 100755 --- a/utils/set_vol_normal.sh +++ b/utils/set_vol_normal.sh @@ -1,4 +1,4 @@ #!/bin/bash +~/GoPi5Go/plib/speak.py 'Volume set to normal 80 percent' 80 amixer -D pulse sset Master 80% -~/GoPi5Go/plib/speak.py 'Volume set to normal 80 percent' diff --git a/utils/set_vol_shout.sh b/utils/set_vol_shout.sh new file mode 100755 index 0000000..5a958b4 --- /dev/null +++ b/utils/set_vol_shout.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +~/GoPi5Go/plib/speak.py 'Volume set to shout at 100 percent' 100 +amixer -D pulse sset Master 100% diff --git a/utils/set_vol_very_very_low.sh b/utils/set_vol_very_very_low.sh index e73a9bc..01cf2c5 100755 --- a/utils/set_vol_very_very_low.sh +++ b/utils/set_vol_very_very_low.sh @@ -1,4 +1,4 @@ #!/bin/bash -amixer -D pulse sset Master 40% -~/GoPi5Go/plib/speak.py 'Volume set very very low at 40 percent' +~/GoPi5Go/plib/speak.py 'Volume set very very low at 45 percent' 45 +amixer -D pulse sset Master 45%