Skip to content

Commit

Permalink
adjust volume adjusters
Browse files Browse the repository at this point in the history
  • Loading branch information
slowrunner committed Sep 15, 2024
1 parent 9526689 commit 7aaa9d6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions plib/speak.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("'","")
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion utils/set_vol_100_pct.sh
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion utils/set_vol_40_pct.sh
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion utils/set_vol_80_pct.sh
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion utils/set_vol_normal.sh
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 4 additions & 0 deletions utils/set_vol_shout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

~/GoPi5Go/plib/speak.py 'Volume set to shout at 100 percent' 100
amixer -D pulse sset Master 100%
4 changes: 2 additions & 2 deletions utils/set_vol_very_very_low.sh
Original file line number Diff line number Diff line change
@@ -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%

0 comments on commit 7aaa9d6

Please sign in to comment.