File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 1212import nvwave
1313from scriptHandler import script
1414import addonHandler
15+ import tones
16+ from synthDriverHandler import getSynth , setSynth
17+ import core
1518
1619# Store original NVDA translation function.
1720nvdaTranslations = _
@@ -39,14 +42,16 @@ def script_cycleAudioOutputDevices(self, gesture):
3942 selection = (selection + 1 ) % len (deviceNames )
4043 audioDevice = deviceNames [selection ]
4144 config .conf ["speech" ]["outputDevice" ] = audioDevice
42- # Reinitialize the tones and speech modules to update the audio device
45+
46+ # Reinitialize the tones module and the synth to update the audio device
4347 # On the contrary to what is written in onOK method of SynthesizerSelectionDialog,
4448 # reinitializing only tones module is not enough.
45- import tones
46- import speech
47- speech .terminate ()
48- tones .terminate ()
49- tones .initialize ()
50- speech .initialize ()
51- ui .message (audioDevice )
49+ # Note: we need to reinitialize synth out of a script to avoid an error if the current synth is silence.
50+ def runOutOfScript ():
51+ tones .terminate ()
52+ setSynth (getSynth ().name )
53+ tones .initialize ()
54+ ui .message (audioDevice )
55+ core .callLater (0 , runOutOfScript )
56+ return
5257
You can’t perform that action at this time.
0 commit comments