|
5 | 5 | # Copyright (C) 2006-2023 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee, |
6 | 6 | # Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka, Accessolutions, |
7 | 7 | # Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot, Rob Meredith, Luke Davis, |
8 | | -# Burman's Computer and Education Ltd. |
| 8 | +# Burman's Computer and Education Ltd, Beka Gozalishvili. |
9 | 9 |
|
10 | 10 | import itertools |
11 | 11 | from typing import ( |
|
66 | 66 | from base64 import b16encode |
67 | 67 | import vision |
68 | 68 | from utils.security import objectBelowLockScreenAndWindowsIsLocked |
| 69 | +from utils.synth import getOutputDeviceNames, setOutputDevice |
69 | 70 |
|
70 | 71 |
|
71 | 72 | #: Script category for text review commands. |
@@ -4289,6 +4290,37 @@ def script_cycleParagraphStyle(self, gesture: "inputCore.InputGesture") -> None: |
4289 | 4290 | config.conf["documentNavigation"]["paragraphStyle"] = newFlag.name |
4290 | 4291 | ui.message(newFlag.displayString) |
4291 | 4292 |
|
| 4293 | + def cycleOutputAudioDevices(self, direction: int): |
| 4294 | + deviceNames = getOutputDeviceNames() |
| 4295 | + try: |
| 4296 | + index = deviceNames.index(config.conf["speech"]["outputDevice"]) |
| 4297 | + newIndex = (index + direction) % len(deviceNames) |
| 4298 | + except ValueError: |
| 4299 | + newIndex = 0 |
| 4300 | + device = deviceNames[newIndex] |
| 4301 | + setOutputDevice(device) |
| 4302 | + ui.message(device) |
| 4303 | + |
| 4304 | + @script( |
| 4305 | + description=_( |
| 4306 | + # Translators: Describes the switch to next output device command. |
| 4307 | + "switches to the next output device" |
| 4308 | + ), |
| 4309 | + category=SCRCAT_SPEECH, |
| 4310 | + ) |
| 4311 | + def script_switchToNextOutputDevice(self, gesture: "inputCore.InputGesture") -> None: |
| 4312 | + self.cycleOutputAudioDevices(1) |
| 4313 | + |
| 4314 | + @script( |
| 4315 | + description=_( |
| 4316 | + # Translators: Describes the switch to previous output device command. |
| 4317 | + "switches to the previous output device" |
| 4318 | + ), |
| 4319 | + category=SCRCAT_SPEECH, |
| 4320 | + ) |
| 4321 | + def script_switchToPreviousOutputDevice(self, gesture: "inputCore.InputGesture") -> None: |
| 4322 | + self.cycleOutputAudioDevices(-1) |
| 4323 | + |
4292 | 4324 |
|
4293 | 4325 | #: The single global commands instance. |
4294 | 4326 | #: @type: L{GlobalCommands} |
|
0 commit comments