blob: 49eb646b2ba15f72c739607e0dd8bb72b72b8ffb (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Speech related function.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/.talk_text 0 def
/.talk_sound 1 def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% ( text -- )
%
/speak {
% skip leading TAB
dup 0 get '\x09' eq { 1 add } if
/last.spoken xfree
/last.spoken over strdup def
dup _speak { pop return } if
dup retranslate dup rot ne { _speak } if pop
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Say text.
%
% ( str -- bool )
%
% str: text
% bool: sound sample found
%
/_speak {
talk_array {
dup .talk_text get 2 index eq {
.talk_sound get wav.playlater
pop true return
} {
pop
} ifelse
} forall
pop
false
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Load sound samples.
%
% ( -- )
%
/load_talk {
/talk_file "en.tlk" findfile def
talk_file .undef eq { return } if
talk_file getdword 0x692741e8 ne { return } if
locale.texts.en .undef eq {
/locale.texts.en "en_US" "%s.tr" loadtexts def
} if
talk_array .undef ne {
talk_array { free } forall
} if
/talk_array xfree
/talk_array [
0 1 talk_file 4 add getdword 1 sub {
[
exch 8 mul 8 add talk_file add
dup getdword talk_file add cvs
exch 4 add getdword talk_file add
]
} for
] def
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Load sound samples.
%
% ( -- )
%
/load_talk_dialog {
window.dialog
dup .title "Just a second..." put
dup .text "Please wait while speech files are being loaded..." put
dup window.init window.show
load_talk
config.volume sound.setvolume
window.done
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Get english text from translated text.
%
% ( str1 -- str2 )
%
% str1: text
% str2: text in en_US
%
/retranslate {
0 locale.texts {
2 index eq {
locale.texts.en exch aget dup .undef eq { pop dup } if exch pop
return
} if
1 add
} forall
pop
} def
|