1515from logHandler import log
1616from driverHandler import BooleanDriverSetting
1717
18+ from speech .commands import (
19+ IndexCommand ,
20+ CharacterModeCommand ,
21+ LangChangeCommand ,
22+ BreakCommand ,
23+ PitchCommand ,
24+ RateCommand ,
25+ VolumeCommand ,
26+ PhonemeCommand ,
27+ )
28+
1829class SynthDriver (SynthDriver ):
1930 name = "espeak"
2031 description = "eSpeak NG"
@@ -29,14 +40,14 @@ class SynthDriver(SynthDriver):
2940 SynthDriver .VolumeSetting (),
3041 )
3142 supportedCommands = {
32- speech . IndexCommand ,
33- speech . CharacterModeCommand ,
34- speech . LangChangeCommand ,
35- speech . BreakCommand ,
36- speech . PitchCommand ,
37- speech . RateCommand ,
38- speech . VolumeCommand ,
39- speech . PhonemeCommand ,
43+ IndexCommand ,
44+ CharacterModeCommand ,
45+ LangChangeCommand ,
46+ BreakCommand ,
47+ PitchCommand ,
48+ RateCommand ,
49+ VolumeCommand ,
50+ PhonemeCommand ,
4051 }
4152 supportedNotifications = {synthIndexReached , synthDoneSpeaking }
4253
@@ -60,9 +71,9 @@ def _get_language(self):
6071 return self ._language
6172
6273 PROSODY_ATTRS = {
63- speech . PitchCommand : "pitch" ,
64- speech . VolumeCommand : "volume" ,
65- speech . RateCommand : "rate" ,
74+ PitchCommand : "pitch" ,
75+ VolumeCommand : "volume" ,
76+ RateCommand : "rate" ,
6677 }
6778
6879 IPA_TO_ESPEAK = {
@@ -91,16 +102,16 @@ def speak(self,speechSequence):
91102 for item in speechSequence :
92103 if isinstance (item ,str ):
93104 textList .append (self ._processText (item ))
94- elif isinstance (item ,speech . IndexCommand ):
105+ elif isinstance (item , IndexCommand ):
95106 textList .append ("<mark name=\" %d\" />" % item .index )
96- elif isinstance (item ,speech . CharacterModeCommand ):
107+ elif isinstance (item , CharacterModeCommand ):
97108 textList .append ("<say-as interpret-as=\" characters\" >" if item .state else "</say-as>" )
98- elif isinstance (item ,speech . LangChangeCommand ):
109+ elif isinstance (item , LangChangeCommand ):
99110 if langChanged :
100111 textList .append ("</voice>" )
101112 textList .append ("<voice xml:lang=\" %s\" >" % (item .lang if item .lang else defaultLanguage ).replace ('_' ,'-' ))
102113 langChanged = True
103- elif isinstance (item ,speech . BreakCommand ):
114+ elif isinstance (item , BreakCommand ):
104115 textList .append ('<break time="%dms" />' % item .time )
105116 elif type (item ) in self .PROSODY_ATTRS :
106117 if prosody :
@@ -121,7 +132,7 @@ def speak(self,speechSequence):
121132 for attr ,val in prosody .items ():
122133 textList .append (' %s="%d%%"' % (attr ,val ))
123134 textList .append (">" )
124- elif isinstance (item ,speech . PhonemeCommand ):
135+ elif isinstance (item , PhonemeCommand ):
125136 # We can't use str.translate because we want to reject unknown characters.
126137 try :
127138 phonemes = "" .join ([self .IPA_TO_ESPEAK [char ] for char in item .ipa ])
0 commit comments