Guido van Rossum | 3a80c8d | 1994-10-02 11:33:59 +0000 | [diff] [blame^] | 1 | # |
| 2 | # Hum - The singing macintosh |
| 3 | # |
| 4 | import macspeech |
| 5 | import sys |
| 6 | import string |
| 7 | |
| 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} |
| 10 | |
| 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 |