blib/lib/Speech/eSpeak.pm

filter: Statementstmt 27.6% 18 / 65 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 31.5% 6 / 19 Podpod n/a totaltotal 23.3% 24 / 103 CC 10 SCAR 14.5
CC
10
Cov
22%
AUTOLOAD
8.2
new
6.0
language
6.0
CRAP 4.3
↑ Summary const-c.inc »
1 package Speech::eSpeak;
2  
3 # use 5.008008;
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 require Exporter;
9 1 ▶use AutoLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=21.1
136 # This AUTOLOAD is used to 'autoload' constants from the constant()
137 # XS function.
138  
139 0 my $constname;
140 0 our $AUTOLOAD;
141 0 ($constname = $AUTOLOAD) =~ s/.*:://;
142 0 ▶ croak "&Speech::eSpeak::constant not defined" if $constname eq 'constant';
Branch: 1 branch
BranchTrueFalseTotal
if $constname eq "constant" 0 0 0
143 0 my ($error, $val) = constant($constname);
144 0 ▶ if ($error) { croak $error; }
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
145 {
146 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
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 ▶ *$AUTOLOAD = sub { $val };
Subroutine __ANON__: not called CC=1 SCAR=6.9
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 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
164 0 my %args = @_;
165 0 ▶ $args{datadir} ||= "/usr/share";
Condition0%0/2
$args{"datadir"} ||= "/usr/share"
l!l
00
MC/DC0%0/1
$args{"datadir"} ||= "/usr/share"
$args{"datadir"}
Truth table0%0/2
A
A= $args{"datadir"}
Aresult
11
00
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 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=6.9
175 0 espeak_Synchronize();
176 }
177  
178 0 ▶sub speak {
Subroutine speak: not called CC=2 SCAR=12.2
179 0 my ($self, $text) = @_;
180  
181 0 ▶ if (defined $text) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $text) { } 0 0 0
182 0 ▶ espeak_Synth($text, do { use bytes; length($text) + 1 }, 0, POS_CHARACTER(), 0, espeakCHARS_AUTO() | espeakPHONEMES() | espeakENDPAUSE(), 0, 0);
Subroutine BEGIN: called CC=1 SCAR=0.6
183 } else {
184 0 carp('speaking text undefined!');
185 }
186 }
187  
188 0 ▶sub stop {
Subroutine stop: not called CC=1 SCAR=6.9
189 0 espeak_Cancel();
190 }
191  
192 0 ▶sub synchronize {
Subroutine synchronize: not called CC=1 SCAR=6.9
193 0 espeak_Synchronize();
194 }
195  
196 0 ▶sub is_playing {
Subroutine is_playing: not called CC=1 SCAR=6.9
197 0 return espeak_IsPlaying();
198 }
199  
200 0 ▶sub language {
Subroutine language: not called CC=2 SCAR=17.9
201 0 my ($self, $lang) = @_;
202  
203 0 ▶ if ($lang) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang) { } 0 0 0
204 0 return espeak_SetVoiceByName($lang);
205 } else {
206 0 my $voice = espeak_GetCurrentVoice();
207 0 return $voice->{identifier};
208 }
209 }
210  
211 0 ▶sub pitch {
Subroutine pitch: not called CC=2 SCAR=17.9
212 0 my ($self, $pitch) = @_;
213  
214 0 ▶ if (defined $pitch) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pitch) { } 0 0 0
215 0 espeak_SetParameter(espeakPITCH(), $pitch, 0);
216 } else {
217 0 espeak_GetParameter(espeakPITCH(), 1);
218 }
219 }
220  
221 0 ▶sub range {
Subroutine range: not called CC=2 SCAR=17.9
222 0 my ($self, $range) = @_;
223 0 ▶ if (defined $range) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $range) { } 0 0 0
224 0 espeak_SetParameter(espeakRANGE(), $range, 0);
225 } else {
226 0 espeak_GetParameter(espeakRANGE(), 1);
227 }
228 }
229  
230 0 ▶sub rate {
Subroutine rate: not called CC=2 SCAR=17.9
231 0 my ($self, $rate) = @_;
232 0 ▶ if ($rate) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rate) { } 0 0 0
233 0 espeak_SetParameter(espeakRATE(), $rate, 0);
234 } else {
235 0 espeak_GetParameter(espeakRATE(), 1);
236 }
237 }
238  
239 0 ▶sub volume {
Subroutine volume: not called CC=2 SCAR=17.9
240 0 my ($self, $volume) = @_;
241 0 ▶ if (defined $volume) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $volume) { } 0 0 0
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__
↑ Summary const-c.inc »