summaryrefslogtreecommitdiffstats
path: root/Mac/Demo/speech/hum.py
blob: ac054719d1c1c320c4fe593650403c15904b4af5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# Hum - The singing macintosh
#
import macspeech
import sys
import string

dict = { 'A':57, 'A#':58, 'B':59, 'C':60, 'C#':61, 'D':62, 'D#':63,
		 'E':64, 'F':65, 'F#':66, 'G':67, 'G#':68}

vd = macspeech.GetIndVoice(2)
vc = vd.NewChannel()
print 'Input strings of notes, as in A B C C# D'
while 1:
	print 'S(tr)ing-',
	str = sys.stdin.readline()
	if not str:
		break
	str = string.split(str[:-1])
	data = []
	for s in str:
		if not dict.has_key(s):
			print 'No such note:', s
		else:
			data.append(dict[s])
	print data
	for d in data:
		vc.SetPitch(float(d))
		vc.SpeakText('la')
		while macspeech.Busy():
			pass