Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3a80c8de
Kaydet (Commit)
3a80c8de
authored
Eki 02, 1994
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add files by Jack
üst
950d47fd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
277 additions
and
0 deletions
+277
-0
SCRIPT
Mac/Demo/speech/SCRIPT
+0
-0
grail.py
Mac/Demo/speech/grail.py
+228
-0
hum.py
Mac/Demo/speech/hum.py
+31
-0
README
Mac/Modules/macspeech/README
+18
-0
macspeechmodule.c
Mac/Modules/macspeechmodule.c
+0
-0
No files found.
Mac/Demo/speech/SCRIPT
0 → 100644
Dosyayı görüntüle @
3a80c8de
This diff is collapsed.
Click to expand it.
Mac/Demo/speech/grail.py
0 → 100644
Dosyayı görüntüle @
3a80c8de
# Pass this program the Holy Grail script on stdin.
import
sys
import
string
import
stdwin
from
stdwinevents
import
*
try
:
import
macspeech
except
ImportError
:
macspeech
=
None
WINWIDTH
=
1000
scrw
,
scrh
=
stdwin
.
getscrsize
()
if
WINWIDTH
>
0.8
*
scrw
:
WINWIDTH
=
int
(
0.8
*
scrw
)
BLACK
=
stdwin
.
fetchcolor
(
'black'
)
RED
=
stdwin
.
fetchcolor
(
'red'
)
BLUE
=
stdwin
.
fetchcolor
(
'blue'
)
done
=
'done'
class
MacSpeaker
:
def
__init__
(
self
):
self
.
voices
=
[]
self
.
nvoices
=
macspeech
.
CountVoices
()
self
.
curvoice
=
1
self
.
rate
=
1.0
def
_newvoice
(
self
):
vd
=
macspeech
.
GetIndVoice
(
self
.
curvoice
)
sc
=
vd
.
NewChannel
()
self
.
curvoice
=
self
.
curvoice
+
1
if
self
.
curvoice
>
self
.
nvoices
:
self
.
curvoice
=
1
return
sc
def
newvoices
(
self
,
n
):
self
.
voices
=
[]
for
i
in
range
(
n
):
self
.
voices
.
append
(
self
.
_newvoice
())
if
self
.
rate
<>
1.0
:
self
.
setrate
(
1.0
)
def
setrate
(
self
,
factor
):
self
.
rate
=
self
.
rate
*
factor
for
v
in
self
.
voices
:
r
=
v
.
GetRate
()
v
.
SetRate
(
r
*
factor
)
def
speak
(
self
,
i
,
text
):
self
.
voices
[
i
-
1
]
.
SpeakText
(
text
)
def
busy
(
self
):
return
macspeech
.
Busy
()
[
NOTHING
,
NEWSCENE
,
ACT
,
TEXT
,
MORETEXT
]
=
range
(
5
)
def
parseline
(
line
):
stripline
=
string
.
strip
(
line
)
if
not
stripline
:
return
NOTHING
,
''
if
stripline
[:
5
]
==
'Scene'
:
return
NEWSCENE
,
stripline
if
line
[
0
]
==
'['
:
return
ACT
,
stripline
if
line
[
0
]
==
' '
and
':'
in
line
:
splitline
=
string
.
splitfields
(
stripline
,
':'
)
stripline
=
string
.
joinfields
(
splitline
[
1
:],
':'
)
return
TEXT
,
(
splitline
[
0
],
string
.
strip
(
stripline
))
return
MORETEXT
,
stripline
def
readscript
(
file
):
lines
=
file
.
readlines
()
acts
=
[]
actor_dict
=
{}
longest
=
0
prev_act
=
0
for
i
in
range
(
len
(
lines
)):
tp
,
data
=
parseline
(
lines
[
i
])
if
tp
==
NEWSCENE
:
acts
.
append
(
actor_dict
.
keys
(),
lines
[
prev_act
:
i
])
prev_act
=
i
actor_dict
=
{}
elif
tp
==
TEXT
:
actor_dict
[
data
[
0
]]
=
1
lines
[
i
]
=
tp
,
data
return
acts
[
1
:]
class
Main
:
def
__init__
(
self
):
if
macspeech
:
self
.
speaker
=
MacSpeaker
()
else
:
self
.
speaker
=
None
sys
.
stdin
=
open
(
'SCRIPT'
,
'r'
)
self
.
acts
=
readscript
(
sys
.
stdin
)
maxactor
=
0
for
actorlist
,
actdata
in
self
.
acts
:
if
len
(
actorlist
)
>
maxactor
:
maxactor
=
len
(
actorlist
)
if
not
self
.
loadnextact
():
print
'No acts to play!'
raise
done
self
.
lh
=
stdwin
.
lineheight
()
self
.
winheight
=
(
maxactor
+
2
)
*
self
.
lh
stdwin
.
setdefwinsize
(
WINWIDTH
,
self
.
winheight
)
self
.
win
=
stdwin
.
open
(
'The Play'
)
self
.
win
.
setdocsize
(
WINWIDTH
,
self
.
winheight
)
self
.
win
.
change
(((
0
,
0
),(
WINWIDTH
,
self
.
winheight
)))
self
.
menu
=
self
.
win
.
menucreate
(
'Play'
)
self
.
menu
.
additem
(
'Faster'
,
'+'
)
self
.
menu
.
additem
(
'Slower'
,
'-'
)
self
.
menu
.
additem
(
'Quit'
,
'Q'
)
self
.
speed
=
4
def
done
(
self
):
del
self
.
win
del
self
.
menu
def
loadnextact
(
self
):
if
not
self
.
acts
:
return
0
actors
,
lines
=
self
.
acts
[
0
]
del
self
.
acts
[
0
]
prevactor
=
0
for
i
in
range
(
len
(
lines
)):
tp
,
data
=
lines
[
i
]
if
tp
==
NOTHING
:
continue
elif
tp
in
(
NEWSCENE
,
ACT
):
lines
[
i
]
=
0
,
data
elif
tp
==
TEXT
:
prevactor
=
actors
.
index
(
data
[
0
])
lines
[
i
]
=
prevactor
+
1
,
data
[
1
]
else
:
lines
[
i
]
=
prevactor
+
1
,
data
self
.
lines
=
lines
self
.
actors
=
[
''
]
+
actors
self
.
actorlines
=
[
''
]
*
len
(
self
.
actors
)
if
self
.
speaker
:
self
.
speaker
.
newvoices
(
len
(
self
.
actors
)
-
1
)
self
.
prevline
=
0
self
.
actwidth
=
0
for
a
in
self
.
actors
:
w
=
stdwin
.
textwidth
(
a
)
if
w
>
self
.
actwidth
:
self
.
actwidth
=
w
return
1
def
loadnextline
(
self
):
if
not
self
.
lines
:
return
0
self
.
actorlines
[
self
.
prevline
]
=
''
top
=
self
.
lh
*
self
.
prevline
self
.
win
.
change
(((
0
,
top
),
(
WINWIDTH
,
top
+
self
.
lh
)))
line
,
data
=
self
.
lines
[
0
]
del
self
.
lines
[
0
]
self
.
actorlines
[
line
]
=
data
self
.
prevline
=
line
top
=
self
.
lh
*
self
.
prevline
self
.
win
.
change
(((
0
,
top
),
(
WINWIDTH
,
top
+
self
.
lh
)))
if
line
==
0
:
self
.
win
.
settimer
(
5
*
self
.
speed
)
else
:
if
self
.
speaker
:
self
.
speaker
.
speak
(
line
,
data
)
tv
=
1
else
:
nwords
=
len
(
string
.
split
(
data
))
tv
=
self
.
speed
*
(
nwords
+
1
)
self
.
win
.
settimer
(
tv
)
return
1
def
timerevent
(
self
):
if
self
.
speaker
and
self
.
speaker
.
busy
():
self
.
win
.
settimer
(
1
)
return
while
1
:
if
self
.
loadnextline
():
return
if
not
self
.
loadnextact
():
stdwin
.
message
(
'The END'
)
self
.
win
.
close
()
raise
done
self
.
win
.
change
(((
0
,
0
),
(
WINWIDTH
,
self
.
winheight
)))
def
redraw
(
self
,
top
,
bottom
,
draw
):
for
i
in
range
(
len
(
self
.
actors
)):
tpos
=
i
*
self
.
lh
bpos
=
(
i
+
1
)
*
self
.
lh
-
1
if
tpos
<
bottom
and
bpos
>
top
:
draw
.
setfgcolor
(
BLUE
)
draw
.
text
((
0
,
tpos
),
self
.
actors
[
i
])
if
i
==
0
:
draw
.
setfgcolor
(
RED
)
else
:
draw
.
setfgcolor
(
BLACK
)
draw
.
text
((
self
.
actwidth
+
5
,
tpos
),
self
.
actorlines
[
i
])
def
run
(
self
):
self
.
win
.
settimer
(
10
)
while
1
:
ev
,
win
,
arg
=
stdwin
.
getevent
()
if
ev
==
WE_DRAW
:
((
left
,
top
),
(
right
,
bot
))
=
arg
self
.
redraw
(
top
,
bot
,
self
.
win
.
begindrawing
())
elif
ev
==
WE_TIMER
:
self
.
timerevent
()
elif
ev
==
WE_CLOSE
:
self
.
win
.
close
()
raise
done
elif
ev
==
WE_MENU
and
arg
[
0
]
==
self
.
menu
:
if
arg
[
1
]
==
0
:
if
self
.
speed
>
1
:
self
.
speed
=
self
.
speed
/
2
if
self
.
speaker
:
self
.
speaker
.
setrate
(
1.4
)
elif
arg
[
1
]
==
1
:
self
.
speed
=
self
.
speed
*
2
if
self
.
speaker
:
self
.
speaker
.
setrate
(
0.7
)
elif
arg
[
1
]
==
2
:
self
.
win
.
close
()
raise
done
if
1
:
main
=
Main
()
try
:
main
.
run
()
except
done
:
pass
del
main
Mac/Demo/speech/hum.py
0 → 100644
Dosyayı görüntüle @
3a80c8de
#
# 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
Mac/Modules/macspeech/README
0 → 100644
Dosyayı görüntüle @
3a80c8de
To add this stuff to Macintosh python (and have some use for it):
1. Obtain a copy of the Speech Manager. It can be found on
ftp.apple.com.
2. Put the Speech.h file from the Speech Manager distribution and
macspeechmodule.c in your python Modules directory.
3. Add the new module to python and build a new python.
4. Install the Speech Manager (under sys7 the extension goes in the
Extensions folder, the data file in the System folder) and reboot.
5. Try it.
The test program 'hum' does that, you type notes and it hums them
(badly, addmitted, but that isn't my fault really).
The test program 'grail' is more fun, but you need stdwin support for
it. It reads the script for the Holy Grail film from the file SCRIPT
and both animates it (text only:-) on the screen and reads it out the
speaker. It will use all voices available in the system.
Mac/Modules/macspeechmodule.c
0 → 100644
Dosyayı görüntüle @
3a80c8de
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment