Skip to content

Commit 3e0cb22

Browse files
authored
Allow passing espeak options to Sound.speak (#218)
My main motivation is to allow controll over words-per-minute rate, but I guess there are other possible uses.
1 parent fd9fe07 commit 3e0cb22

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ev3dev/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,9 +2814,10 @@ def play(wav_file):
28142814
return Popen('/usr/bin/aplay -q "%s"' % wav_file, stdout=n, shell=True)
28152815

28162816
@staticmethod
2817-
def speak(text):
2817+
def speak(text, espeak_opts='-a 200 -s 130'):
28182818
"""
28192819
Speak the given text aloud.
28202820
"""
28212821
with open(os.devnull, 'w') as n:
2822-
return Popen('/usr/bin/espeak -a 200 --stdout "%s" | /usr/bin/aplay -q' % text, stdout=n, shell=True)
2822+
cmd_line = '/usr/bin/espeak --stdout {0} "{1}" | /usr/bin/aplay -q'.format(espeak_opts, text)
2823+
return Popen(cmd_line, stdout=n, shell=True)

0 commit comments

Comments
 (0)