line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Speech::eSpeak; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# use 5.008008; |
4
|
1
|
|
|
1
|
|
21030
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
108
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
1
|
|
|
1
|
|
1872
|
use AutoLoader; |
|
1
|
|
|
|
|
2084
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
14
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
15
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# This allows declaration use Speech::eSpeak ':all'; |
18
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
19
|
|
|
|
|
|
|
# will save memory. |
20
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
21
|
|
|
|
|
|
|
AUDIO_OUTPUT_PLAYBACK |
22
|
|
|
|
|
|
|
AUDIO_OUTPUT_RETRIEVAL |
23
|
|
|
|
|
|
|
AUDIO_OUTPUT_SYNCHRONOUS |
24
|
|
|
|
|
|
|
EE_BUFFER_FULL |
25
|
|
|
|
|
|
|
EE_INTERNAL_ERROR |
26
|
|
|
|
|
|
|
EE_OK |
27
|
|
|
|
|
|
|
N_SPEECH_PARAM |
28
|
|
|
|
|
|
|
POS_CHARACTER |
29
|
|
|
|
|
|
|
POS_SENTENCE |
30
|
|
|
|
|
|
|
POS_WORD |
31
|
|
|
|
|
|
|
espeakCAPITALS |
32
|
|
|
|
|
|
|
espeakCHARS_8BIT |
33
|
|
|
|
|
|
|
espeakCHARS_AUTO |
34
|
|
|
|
|
|
|
espeakCHARS_UTF8 |
35
|
|
|
|
|
|
|
espeakCHARS_WCHAR |
36
|
|
|
|
|
|
|
espeakEMPHASIS |
37
|
|
|
|
|
|
|
espeakENDPAUSE |
38
|
|
|
|
|
|
|
espeakEVENT_LIST_TERMINATED |
39
|
|
|
|
|
|
|
espeakEVENT_WORD |
40
|
|
|
|
|
|
|
espeakEVENT_SENTENCE |
41
|
|
|
|
|
|
|
espeakEVENT_MARK |
42
|
|
|
|
|
|
|
espeakEVENT_PLAY |
43
|
|
|
|
|
|
|
espeakEVENT_END |
44
|
|
|
|
|
|
|
espeakEVENT_MSG_TERMINATED |
45
|
|
|
|
|
|
|
espeakEVENT_PHONEME |
46
|
|
|
|
|
|
|
espeakKEEP_NAMEDATA |
47
|
|
|
|
|
|
|
espeakLINELENGTH |
48
|
|
|
|
|
|
|
espeakPHONEMES |
49
|
|
|
|
|
|
|
espeakPITCH |
50
|
|
|
|
|
|
|
espeakPUNCTUATION |
51
|
|
|
|
|
|
|
espeakPUNCT_ALL |
52
|
|
|
|
|
|
|
espeakPUNCT_NONE |
53
|
|
|
|
|
|
|
espeakPUNCT_SOME |
54
|
|
|
|
|
|
|
espeakRANGE |
55
|
|
|
|
|
|
|
espeakRATE |
56
|
|
|
|
|
|
|
espeakSILENCE |
57
|
|
|
|
|
|
|
espeakSSML |
58
|
|
|
|
|
|
|
espeakVOLUME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
espeak_Initialize |
61
|
|
|
|
|
|
|
espeak_SetSynthCallback |
62
|
|
|
|
|
|
|
espeak_SetUriCallback |
63
|
|
|
|
|
|
|
espeak_Synth |
64
|
|
|
|
|
|
|
espeak_Synth_Mark |
65
|
|
|
|
|
|
|
espeak_Key |
66
|
|
|
|
|
|
|
espeak_Char |
67
|
|
|
|
|
|
|
espeak_SetParameter |
68
|
|
|
|
|
|
|
espeak_GetParameter |
69
|
|
|
|
|
|
|
espeak_SetPunctuationList |
70
|
|
|
|
|
|
|
espeak_SetPhonemeTrace |
71
|
|
|
|
|
|
|
espeak_CompileDictionary |
72
|
|
|
|
|
|
|
espeak_ListVoices |
73
|
|
|
|
|
|
|
espeak_SetVoiceByName |
74
|
|
|
|
|
|
|
espeak_SetVoiceByProperties |
75
|
|
|
|
|
|
|
espeak_GetCurrentVoice |
76
|
|
|
|
|
|
|
espeak_Cancel |
77
|
|
|
|
|
|
|
espeak_IsPlaying |
78
|
|
|
|
|
|
|
espeak_Synchronize |
79
|
|
|
|
|
|
|
espeak_Terminate |
80
|
|
|
|
|
|
|
espeak_Info |
81
|
|
|
|
|
|
|
set_male_voice |
82
|
|
|
|
|
|
|
set_female_voice |
83
|
|
|
|
|
|
|
) ] ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
our @EXPORT = qw( |
88
|
|
|
|
|
|
|
AUDIO_OUTPUT_PLAYBACK |
89
|
|
|
|
|
|
|
AUDIO_OUTPUT_RETRIEVAL |
90
|
|
|
|
|
|
|
AUDIO_OUTPUT_SYNCHRONOUS |
91
|
|
|
|
|
|
|
Audio |
92
|
|
|
|
|
|
|
EE_BUFFER_FULL |
93
|
|
|
|
|
|
|
EE_INTERNAL_ERROR |
94
|
|
|
|
|
|
|
EE_OK |
95
|
|
|
|
|
|
|
End |
96
|
|
|
|
|
|
|
Mark |
97
|
|
|
|
|
|
|
N_SPEECH_PARAM |
98
|
|
|
|
|
|
|
POS_CHARACTER |
99
|
|
|
|
|
|
|
POS_SENTENCE |
100
|
|
|
|
|
|
|
POS_WORD |
101
|
|
|
|
|
|
|
Retrieval |
102
|
|
|
|
|
|
|
Start |
103
|
|
|
|
|
|
|
espeakCAPITALS |
104
|
|
|
|
|
|
|
espeakCHARS_8BIT |
105
|
|
|
|
|
|
|
espeakCHARS_AUTO |
106
|
|
|
|
|
|
|
espeakCHARS_UTF8 |
107
|
|
|
|
|
|
|
espeakCHARS_WCHAR |
108
|
|
|
|
|
|
|
espeakEMPHASIS |
109
|
|
|
|
|
|
|
espeakENDPAUSE |
110
|
|
|
|
|
|
|
espeakEVENT_LIST_TERMINATED |
111
|
|
|
|
|
|
|
espeakEVENT_WORD |
112
|
|
|
|
|
|
|
espeakEVENT_SENTENCE |
113
|
|
|
|
|
|
|
espeakEVENT_MARK |
114
|
|
|
|
|
|
|
espeakEVENT_PLAY |
115
|
|
|
|
|
|
|
espeakEVENT_END |
116
|
|
|
|
|
|
|
espeakEVENT_MSG_TERMINATED |
117
|
|
|
|
|
|
|
espeakEVENT_PHONEME |
118
|
|
|
|
|
|
|
espeakKEEP_NAMEDATA |
119
|
|
|
|
|
|
|
espeakLINELENGTH |
120
|
|
|
|
|
|
|
espeakPHONEMES |
121
|
|
|
|
|
|
|
espeakPITCH |
122
|
|
|
|
|
|
|
espeakPUNCTUATION |
123
|
|
|
|
|
|
|
espeakPUNCT_ALL |
124
|
|
|
|
|
|
|
espeakPUNCT_NONE |
125
|
|
|
|
|
|
|
espeakPUNCT_SOME |
126
|
|
|
|
|
|
|
espeakRANGE |
127
|
|
|
|
|
|
|
espeakRATE |
128
|
|
|
|
|
|
|
espeakSILENCE |
129
|
|
|
|
|
|
|
espeakSSML |
130
|
|
|
|
|
|
|
espeakVOLUME |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
our $VERSION = '0.4'; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub AUTOLOAD { |
136
|
|
|
|
|
|
|
# This AUTOLOAD is used to 'autoload' constants from the constant() |
137
|
|
|
|
|
|
|
# XS function. |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
0
|
|
|
my $constname; |
140
|
0
|
|
|
|
|
|
our $AUTOLOAD; |
141
|
0
|
|
|
|
|
|
($constname = $AUTOLOAD) =~ s/.*:://; |
142
|
0
|
0
|
|
|
|
|
croak "&Speech::eSpeak::constant not defined" if $constname eq 'constant'; |
143
|
0
|
|
|
|
|
|
my ($error, $val) = constant($constname); |
144
|
0
|
0
|
|
|
|
|
if ($error) { croak $error; } |
|
0
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
{ |
146
|
1
|
|
|
1
|
|
309
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
255
|
|
|
0
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Fixed between 5.005_53 and 5.005_61 |
148
|
|
|
|
|
|
|
#XXX if ($] >= 5.00561) { |
149
|
|
|
|
|
|
|
#XXX *$AUTOLOAD = sub () { $val }; |
150
|
|
|
|
|
|
|
#XXX } |
151
|
|
|
|
|
|
|
#XXX else { |
152
|
0
|
|
|
0
|
|
|
*$AUTOLOAD = sub { $val }; |
|
0
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#XXX } |
154
|
|
|
|
|
|
|
} |
155
|
0
|
|
|
|
|
|
goto &$AUTOLOAD; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
require XSLoader; |
159
|
|
|
|
|
|
|
XSLoader::load('Speech::eSpeak', $VERSION); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Preloaded methods go here. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub new { |
164
|
0
|
|
|
0
|
|
|
my %args = @_; |
165
|
0
|
|
0
|
|
|
|
$args{datadir} ||= "/usr/share"; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK(), 0, $args{datadir}, 0); |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $self = {}; |
170
|
0
|
|
|
|
|
|
bless $self, __PACKAGE__; |
171
|
0
|
|
|
|
|
|
return $self; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub DESTROY { |
175
|
0
|
|
|
0
|
|
|
espeak_Synchronize(); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub speak { |
179
|
0
|
|
|
0
|
|
|
my ($self, $text) = @_; |
180
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
if (defined $text) { |
182
|
1
|
|
|
1
|
|
1167
|
espeak_Synth($text, do { use bytes; length($text) + 1 }, 0, POS_CHARACTER(), 0, espeakCHARS_AUTO() | espeakPHONEMES() | espeakENDPAUSE(), 0, 0); |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
5
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
} else { |
184
|
0
|
|
|
|
|
|
carp('speaking text undefined!'); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub stop { |
189
|
0
|
|
|
0
|
|
|
espeak_Cancel(); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub synchronize { |
193
|
0
|
|
|
0
|
|
|
espeak_Synchronize(); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub is_playing { |
197
|
0
|
|
|
0
|
|
|
return espeak_IsPlaying(); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub language { |
201
|
0
|
|
|
0
|
|
|
my ($self, $lang) = @_; |
202
|
|
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
if ($lang) { |
204
|
0
|
|
|
|
|
|
return espeak_SetVoiceByName($lang); |
205
|
|
|
|
|
|
|
} else { |
206
|
0
|
|
|
|
|
|
my $voice = espeak_GetCurrentVoice(); |
207
|
0
|
|
|
|
|
|
return $voice->{identifier}; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub pitch { |
212
|
0
|
|
|
0
|
|
|
my ($self, $pitch) = @_; |
213
|
|
|
|
|
|
|
|
214
|
0
|
0
|
|
|
|
|
if (defined $pitch) { |
215
|
0
|
|
|
|
|
|
espeak_SetParameter(espeakPITCH(), $pitch, 0); |
216
|
|
|
|
|
|
|
} else { |
217
|
0
|
|
|
|
|
|
espeak_GetParameter(espeakPITCH(), 1); |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub range { |
222
|
0
|
|
|
0
|
|
|
my ($self, $range) = @_; |
223
|
0
|
0
|
|
|
|
|
if (defined $range) { |
224
|
0
|
|
|
|
|
|
espeak_SetParameter(espeakRANGE(), $range, 0); |
225
|
|
|
|
|
|
|
} else { |
226
|
0
|
|
|
|
|
|
espeak_GetParameter(espeakRANGE(), 1); |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub rate { |
231
|
0
|
|
|
0
|
|
|
my ($self, $rate) = @_; |
232
|
0
|
0
|
|
|
|
|
if ($rate) { |
233
|
0
|
|
|
|
|
|
espeak_SetParameter(espeakRATE(), $rate, 0); |
234
|
|
|
|
|
|
|
} else { |
235
|
0
|
|
|
|
|
|
espeak_GetParameter(espeakRATE(), 1); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub volume { |
240
|
0
|
|
|
0
|
|
|
my ($self, $volume) = @_; |
241
|
0
|
0
|
|
|
|
|
if (defined $volume) { |
242
|
0
|
|
|
|
|
|
espeak_SetParameter(espeakVOLUME(), $volume, 0); |
243
|
|
|
|
|
|
|
} else { |
244
|
0
|
|
|
|
|
|
espeak_GetParameter(espeakVOLUME(), 1); |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
1; |
251
|
|
|
|
|
|
|
__END__ |