Added 'list_only' option (and modified 'run()' to respect it).
[python/dscho.git] / Mac / Demo / speech / hum.py
blobac054719d1c1c320c4fe593650403c15904b4af5
2 # Hum - The singing macintosh
4 import macspeech
5 import sys
6 import string
8 dict = { 'A':57, 'A#':58, 'B':59, 'C':60, 'C#':61, 'D':62, 'D#':63,
9 'E':64, 'F':65, 'F#':66, 'G':67, 'G#':68}
11 vd = macspeech.GetIndVoice(2)
12 vc = vd.NewChannel()
13 print 'Input strings of notes, as in A B C C# D'
14 while 1:
15 print 'S(tr)ing-',
16 str = sys.stdin.readline()
17 if not str:
18 break
19 str = string.split(str[:-1])
20 data = []
21 for s in str:
22 if not dict.has_key(s):
23 print 'No such note:', s
24 else:
25 data.append(dict[s])
26 print data
27 for d in data:
28 vc.SetPitch(float(d))
29 vc.SpeakText('la')
30 while macspeech.Busy():
31 pass