3030from synthDriverHandler import (
3131 SynthDriver ,
3232 VoiceInfo ,
33+ getSynth ,
3334 synthDoneSpeaking ,
3435 synthIndexReached ,
3536)
@@ -89,7 +90,7 @@ class SynthDriver(SynthDriver):
8990# SynthDriver.VariantSetting(),
9091 SynthDriver .RateSetting (),
9192# SynthDriver.RateBoostSetting(),
92- # SynthDriver.PitchSetting(),
93+ # SynthDriver.PitchSetting(),
9394# SynthDriver.InflectionSetting(),
9495 SynthDriver .VolumeSetting (),
9596 )
@@ -124,27 +125,26 @@ def __init__(self):
124125 if not self .check ():
125126 return
126127 log .info ("H2R NG: init started" )
127- # confspec = {
128- # "engSynth": "string(default='oneCore')",
129- # "engVoice": "string(default='')",
130- # "engVariant": "string(default='')",
131- # "engRate": "integer(default=50)",
132- # "engPitch": "integer(default=50)",
133- # "engVolume": "integer(default=100)",
134- # "engInflection": "integer(default=80)",
135- # "showStartupMsg": "boolean(default=True)"
136- # }
137-
138- # config.conf.spec["hear2read"] = confspec
139- # config.conf.save()
140128
141129 # Have H2R pitch be set to the engsynth value to allow PitchCommand
142130 # to be used for capitals
131+ confspec_default = {
132+ "voice" : f"string(default='{ _H2R_NG_Speak .en_voice } ')" ,
133+ "rate" : "integer(default=50)" ,
134+ "pitch" : "integer(default=50)" ,
135+ "volume" : "integer(default=100)" ,
136+ "capPitchChange" : "integer(default=30)" ,
137+ }
138+ config .conf .spec ["speech" ][self .name ] = confspec_default
139+ config .conf .save ()
140+
143141 try :
144- config .conf ["speech" ][self .name ]["pitch" ] = _h2r_config [SCT_EngSynth ][ID_EnglishSynthPitch ]
142+ tempPitch = _h2r_config [SCT_EngSynth ][ID_EnglishSynthPitch ]
143+ # log.info(f"H2R NG got eng pitch: {tempPitch}, {type(tempPitch)}")
144+ config .conf ["speech" ][self .name ]["pitch" ] = int (tempPitch )#_h2r_config[SCT_EngSynth][ID_EnglishSynthPitch]
145145 except KeyError as e :
146146 if self .name in str (e ):
147- log .warn ("Hear2Read no config found, updating default config" )
147+ log .warn ("Hear2Read no config found, retrying default config" )
148148 confspec_default = {
149149 "voice" : f"string(default='{ _H2R_NG_Speak .en_voice } ')" ,
150150 "rate" : "integer(default=50)" ,
@@ -154,6 +154,12 @@ def __init__(self):
154154 }
155155 config .conf .spec ["speech" ][self .name ] = confspec_default
156156 config .conf .save ()
157+
158+ h2rpitch = config .conf ["speech" ][self .name ]["pitch" ]
159+
160+ # log.info(f"Hear2ReadNG: set pitch to: {h2rpitch}, {type(h2rpitch)}")
161+
162+ config .conf .save ()
157163
158164 _H2R_NG_Speak .initialize (self ._onIndexReached )
159165
@@ -206,6 +212,7 @@ def speak(self, speechSequence: SpeechSequence):
206212 # log.info("H2R speak")
207213 # log.info(f"speech sequence: {speechSequence}")
208214 self .subsequences = []
215+ self .first_subseq = True
209216 if self .is_curr_voice_eng () or not self ._get_voice ():
210217 # self.subsequences.append(speechSequence)
211218 _H2R_NG_Speak .speak_eng (speech_sequence = speechSequence )
@@ -282,8 +289,12 @@ def speak(self, speechSequence: SpeechSequence):
282289 subSequence .append (item )
283290 # pass
284291 elif isinstance (item , PitchCommand ):
285- # log.info(f"Hear2Read got PitchCommand: {PitchCommand }")
292+ # log.info(f"Hear2Read got PitchCommand: {item }")
286293 subSequence .append (item )
294+ # synth = getSynth()
295+ # synthConf = config.conf["speech"][synth.name]
296+ # h2rpitch = synthConf["pitch"]
297+ # log.info(f"Hear2ReadNG: current pitch at: {h2rpitch}, {type(h2rpitch)}")
287298 # pass
288299 elif isinstance (item , VolumeCommand ):
289300 subSequence .append (item )
@@ -389,6 +400,12 @@ def _processSubSequences(self):
389400 # log.info(f"_processSubSequences: isASCII: {isASCII}")
390401 # log.info(f"_processSubsequence: subsequence {subSequence}")
391402
403+ # Play a short silence while switching from Indian language to English
404+ if not self .first_subseq and isASCII :
405+ _H2R_NG_Speak .speak_silence (500 )
406+
407+ self .first_subseq = False
408+
392409 if isinstance (subSequence [- 1 ], IndexCommand ):
393410 self .currIndex = subSequence [- 1 ].index
394411 # log.info(f"index boundary at: {self.currIndex}")
@@ -403,7 +420,7 @@ def _process_non_native_unicode(self, text):
403420 split_texts = []
404421 prev_range = ()
405422 text_bit = ""
406- has_curr_lang = False
423+ # has_curr_lang = False
407424 is_prev_valid_lang = False
408425
409426 # log.info(f"_process_non_native_unicode: {text}")
@@ -413,7 +430,7 @@ def _process_non_native_unicode(self, text):
413430 if self ._script_range [0 ] <= ord (c ) <= self ._script_range [1 ] or c in "।॥" :
414431 # log.info(f"adding: {c}")
415432 text_bit += c
416- has_curr_lang = True
433+ # has_curr_lang = True
417434 is_prev_valid_lang = True
418435 continue
419436
@@ -650,7 +667,7 @@ def _set_script_range(self):
650667 self ._script_range = unicode_ranges ["english" ]
651668 return
652669
653- if lang_iso in ["hi" , "mr" , "ne" ]:
670+ if lang_iso in ["hi" , "mr" , "ne" , "sa" ]:
654671 self ._script_range = unicode_ranges ["devanagari" ]
655672 elif lang_iso in ["as" , "bn" ]:
656673 self ._script_range = unicode_ranges ["bengali" ]
0 commit comments