Skip to content
Next Next commit
Re-add audio combo boxes to synth dialog
  • Loading branch information
codeofdusk committed Sep 21, 2023
commit 4aef139227fc761731c7205c87ad1b13c7ac8a6b
67 changes: 39 additions & 28 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import typing
import wx
from NVDAState import WritePaths
import NVDAState
from buildVersion import version_year

from vision.providerBase import VisionEnhancementProviderSettings
from wx.lib.expando import ExpandoTextCtrl
Expand Down Expand Up @@ -1108,6 +1110,8 @@ def makeSettings(self, settingsSizer):
self.synthList = settingsSizerHelper.addLabeledControl(synthListLabelText, wx.Choice, choices=[])
self.bindHelpEvent("SelectSynthesizerSynthesizer", self.synthList)
self.updateSynthesizerList()
if version_year < 2024 and NVDAState._allowDeprecatedAPI():
Comment thread
codeofdusk marked this conversation as resolved.
Outdated
_addAudioCombos(self, settingsSizerHelper)

def postInit(self):
# Finally, ensure that focus is on the synthlist
Expand All @@ -1130,6 +1134,8 @@ def onOk(self, evt):
# The list of synths has not been populated yet, so we didn't change anything in this panel
return

config.conf["speech"]["outputDevice"] = self.deviceList.GetStringSelection()

newSynth=self.synthNames[self.synthList.GetSelection()]
if not setSynth(newSynth):
_synthWarningDialog(newSynth.name)
Comment thread
codeofdusk marked this conversation as resolved.
Outdated
Expand Down Expand Up @@ -2566,6 +2572,38 @@ def _synthWarningDialog(newSynth: str):
)


def _addAudioCombos(panel, sHelper):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this please get type hints?
Perhaps this could be a static method of AudioPanel, so that when the deprecated code is removed the function still makes sense as a helper function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any thoughts on making this a static method? it will greatly simplify the diff and also simplify reverting in 2024.1

"#15486: temporarily re-add audio options to synth dialog for 2023.3."
# Translators: This is the label for the select output device combo in the synthesizer dialog.
Comment thread
codeofdusk marked this conversation as resolved.
Outdated
# Examples of an output device are default soundcard, usb headphones, etc.
deviceListLabelText = _("Audio output &device:")
deviceNames = nvwave.getOutputDeviceNames()
# #11349: On Windows 10 20H1 and 20H2, Microsoft Sound Mapper returns an empty string.
if deviceNames[0] in ("", "Microsoft Sound Mapper"):
# Translators: name for default (Microsoft Sound Mapper) audio output device.
deviceNames[0] = _("Microsoft Sound Mapper")
panel.deviceList = sHelper.addLabeledControl(deviceListLabelText, wx.Choice, choices=deviceNames)
panel.bindHelpEvent("SelectSynthesizerOutputDevice", panel.deviceList)
try:
selection = deviceNames.index(config.conf["speech"]["outputDevice"])
except ValueError:
selection = 0
panel.deviceList.SetSelection(selection)

# Translators: This is a label for the audio ducking combo box in the Audio Settings dialog.
duckingListLabelText = _("Audio d&ucking mode:")
panel.duckingList = sHelper.addLabeledControl(
duckingListLabelText,
wx.Choice,
choices=[mode.displayString for mode in audioDucking.AudioDuckingMode]
)
panel.bindHelpEvent("SelectSynthesizerDuckingMode", panel.duckingList)
index = config.conf["audio"]["audioDuckingMode"]
panel.duckingList.SetSelection(index)
if not audioDucking.isAudioDuckingSupported():
panel.duckingList.Disable()


class AudioPanel(SettingsPanel):
# Translators: This is the label for the audio settings panel.
title = _("Audio")
Expand All @@ -2574,34 +2612,7 @@ class AudioPanel(SettingsPanel):
def makeSettings(self, settingsSizer: wx.BoxSizer) -> None:
sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer)

# Translators: This is the label for the select output device combo in the synthesizer dialog.
# Examples of an output device are default soundcard, usb headphones, etc.
deviceListLabelText = _("Audio output &device:")
deviceNames = nvwave.getOutputDeviceNames()
# #11349: On Windows 10 20H1 and 20H2, Microsoft Sound Mapper returns an empty string.
if deviceNames[0] in ("", "Microsoft Sound Mapper"):
# Translators: name for default (Microsoft Sound Mapper) audio output device.
deviceNames[0] = _("Microsoft Sound Mapper")
self.deviceList = sHelper.addLabeledControl(deviceListLabelText, wx.Choice, choices=deviceNames)
self.bindHelpEvent("SelectSynthesizerOutputDevice", self.deviceList)
try:
selection = deviceNames.index(config.conf["speech"]["outputDevice"])
except ValueError:
selection = 0
self.deviceList.SetSelection(selection)

# Translators: This is a label for the audio ducking combo box in the Audio Settings dialog.
duckingListLabelText = _("Audio d&ucking mode:")
self.duckingList = sHelper.addLabeledControl(
duckingListLabelText,
wx.Choice,
choices=[mode.displayString for mode in audioDucking.AudioDuckingMode]
)
self.bindHelpEvent("SelectSynthesizerDuckingMode", self.duckingList)
index = config.conf["audio"]["audioDuckingMode"]
self.duckingList.SetSelection(index)
if not audioDucking.isAudioDuckingSupported():
self.duckingList.Disable()
_addAudioCombos(self, sHelper)

# Translators: This is the label for a checkbox control in the
# Audio settings panel.
Expand Down
3 changes: 3 additions & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ There's also been bug fixes for the Add-on Store, Microsoft Office, Microsoft Ed

== New Features ==
- Enhanced sound management:
- New "audio" panel in settings. (#15472)
- Options to control audio output and ducking mode have been relocated to audio settings. They will be removed from the "select synthesizer" dialog in 2024.1. (#15486)
-
Comment thread
codeofdusk marked this conversation as resolved.
Outdated
- An option in Audio settings to have the volume of NVDA sounds and beeps follow the volume setting of the voice you are using. (#1409)
- An option in Audio settings to separately configure the volume of NVDA sounds. (#1409, #15038)
- NVDA will now output audio via the Windows Audio Session API (WASAPI), which may improve the responsiveness, performance and stability of NVDA speech and sounds. (#14697, #11169, #11615, #5096, #10185, #11061)
Expand Down