From f464c71d61f9fdde9cdbc87a820717f96f6465d8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 Feb 2023 12:38:47 +0530 Subject: [PATCH] Use SpeechError not KeyError for failure to find device/voice --- src/calibre/utils/windows/winspeech.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/windows/winspeech.py b/src/calibre/utils/windows/winspeech.py index f9cfef41fe..0727508ac9 100644 --- a/src/calibre/utils/windows/winspeech.py +++ b/src/calibre/utils/windows/winspeech.py @@ -438,7 +438,7 @@ class WinSpeech: val = spec or getattr(default_system_voice, 'id', '__default__') x = self.wait_for('Setting the voice', Voice, related_to=self.send_command(f'voice {val}')) if not x.found: - raise KeyError(f'Failed to find the voice: {val}') + raise SpeechError(f'Failed to find the voice: {val}') def set_audio_device(self, spec, default_system_audio_device): if not spec and not default_system_audio_device: @@ -447,7 +447,7 @@ class WinSpeech: spec = default_system_audio_device.spec() x = self.wait_for('Setting the audio device', AudioDevice, related_to=self.send_command(f'audio_device {spec[0]} {spec[1]}')) if not x.found: - raise KeyError(f'Failed to find the audio device: {spec}') + raise SpeechError(f'Failed to find the audio device: {spec}') def get_audio_device(self): return self.wait_for('Audio device', AudioDevice, related_to=self.send_command('audio_device'))