Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Dec 15, 2024
1 parent 2111d59 commit 919cc6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ovos_tts_plugin_piper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ovos_utils.lang import standardize_lang_tag
from ovos_utils.log import LOG

from ovos_tts_plugin_piper.download import LANG2VOICES, SHORTNAMES, get_voice_files, get_lang_voices, get_default_voice
from ovos_tts_plugin_piper.download import LANG2VOICES, SHORTNAMES, VoiceNotFoundError, get_voice_files, get_lang_voices, get_default_voice
from ovos_tts_plugin_piper.piper import PiperVoice, PiperConfig


Expand Down Expand Up @@ -89,7 +89,11 @@ def get_model(self, lang=None, voice=None, speaker=None):
if voice in PiperTTSPlugin.engines:
return PiperTTSPlugin.engines[voice], speaker

model, model_config = get_voice_files(voice)
try:
model, model_config = get_voice_files(voice)
except VoiceNotFoundError as e:
LOG.error(f"Voice files for '{voice}' not found: {e}")
raise

with open(model_config, "r", encoding="utf-8") as config_file:
config_dict = json.load(config_file)
Expand Down
2 changes: 1 addition & 1 deletion ovos_tts_plugin_piper/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_available_voices(update_voices: bool = False) -> Dict[str, Any]:
shutil.copyfileobj(response, download_file)
except Exception as e:
LOG.error(f"Failed to download {voices_url}: {e}")
raise e

# Prefer downloaded file to embedded
voices_embedded = _DIR / "voices.json"
voices_path = voices_download if voices_download.exists() else voices_embedded
Expand Down

0 comments on commit 919cc6b

Please sign in to comment.