def switchToDefaultOutputDevice(self) -> None: """Switch NVDA audio output to the default audio device.""" device: str = self.getDefaultDeviceName() if config.conf['speech']['outputDevice'] not in ("Microsoft Sound Mapper", device,): config.conf['speech']['outputDevice'] = device if synthDriverHandler.setSynth(synthDriverHandler.getSynth().name): tones.terminate() tones.initialize() if config.conf[ADDON_NAME]['playsound']: self.audioEnabledSound()
def resetConfiguration(factoryDefaults=False): """Loads the configuration, installs the correct language support and initialises audio so that it will use the configured synth and speech settings. """ import config import braille import brailleInput import speech import vision import inputCore import tones log.debug("Terminating vision") vision.terminate() log.debug("Terminating braille") braille.terminate() log.debug("Terminating brailleInput") brailleInput.terminate() log.debug("terminating speech") speech.terminate() log.debug("terminating tones") tones.terminate() log.debug("terminating addonHandler") addonHandler.terminate() log.debug("Reloading config") config.conf.reset(factoryDefaults=factoryDefaults) logHandler.setLogLevelFromConfig() # Language if languageHandler.isLanguageForced(): lang = globalVars.appArgs.language else: lang = config.conf["general"]["language"] log.debug("setting language to %s" % lang) languageHandler.setLanguage(lang) # Addons addonHandler.initialize() # Tones tones.initialize() #Speech log.debug("initializing speech") speech.initialize() #braille log.debug("Initializing brailleInput") brailleInput.initialize() log.debug("Initializing braille") braille.initialize() # Vision log.debug("initializing vision") vision.initialize() log.debug("Reloading user and locale input gesture maps") inputCore.manager.loadUserGestureMap() inputCore.manager.loadLocaleGestureMap() import audioDucking if audioDucking.isAudioDuckingSupported(): audioDucking.handlePostConfigProfileSwitch() log.info("Reverted to saved configuration")
def setOutputDevice(self, name: str) -> None: """Switche the NVDA output to the audio device with the specified name. @param name: name of the audio output device @type name: str """ config.conf['speech']['outputDevice'] = name status: bool = setSynth(getSynth().name) if status: tones.terminate() tones.initialize() ui.message(name)
def finish(synthName, synthspeechConfig, msg): # stop previous synth because oneCore voice switch don't work without it config.conf[SCT_Speech] = synthSpeechConfig.copy() setSynth(synthName) config.conf[SCT_Speech][synthName] = synthSpeechConfig[ synthName].copy() getSynth().loadSettings() # Reinitialize the tones module to update the audio device import tones tones.terminate() tones.initialize() if msg: ui.message(msg)
def setOutputDevice(synth, outputDevice): import speech speech.cancelSpeech() prevOutputDevice = config.conf["speech"]["outputDevice"] config.conf["speech"]["outputDevice"] = outputDevice # Reinitialize the tones module to update the audio device import tones tones.terminate() if not setSynth(synth.name): log.error("Could not load the %s synthesizer." % synth) ret = False else: ret = True tones.initialize() config.conf["speech"]["outputDevice"] = prevOutputDevice return ret
def callback(deviceName): # to send a tone on the selected output device from synthDriverHandler import _audioOutputDevice curOutputDevice = _audioOutputDevice config.conf["speech"]["outputDevice"] = deviceName # Reinitialize the tones module to update the audio device import tones tones.terminate() tones.initialize() tones.beep(250, 100) time.sleep(0.3) tones.beep(350, 100) time.sleep(0.3) config.conf["speech"]["outputDevice"] = curOutputDevice # Reinitialize the tones module to update the audio device to the current output device import tones tones.terminate() tones.initialize()