From 97b2b2e5c63ca94f619dd2f8fbe069486f2b2856 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Thu, 03 Mar 2011 02:22:39 +0000 Subject: added pitch option --- (limited to 'pysamples/speak.py') diff --git a/pysamples/speak.py b/pysamples/speak.py index 666fc6b..e8d3864 100644 --- a/pysamples/speak.py +++ b/pysamples/speak.py @@ -23,7 +23,7 @@ # palette is selected. -def myblock(lc, text): +def myblock(lc, arg): ########################################################################### # @@ -33,9 +33,24 @@ def myblock(lc, text): import os + pitch = None + if type(arg) == type([]): + text = arg[0] + if len(arg) > 1: + pitch = int(arg[1]) + if pitch > 99: + pitch = 99 + elif pitch < 0: + pitch = 0 + else: + text = arg + # Turtle Art numbers are passed as float, # but they may be integer values. if type(text) == float and int(text) == text: text = int(text) - os.system('espeak "%s" --stdout | aplay' % (text)) + if pitch is None: + os.system('espeak "%s" --stdout | aplay' % (text)) + else: + os.system('espeak "%s" -p "%s" --stdout | aplay' % (text, pitch)) -- cgit v0.9.1