Skip to content

Commit

Permalink
Fix sentencesplitter exception when can't find file
Browse files Browse the repository at this point in the history
  • Loading branch information
1over137 committed Jan 22, 2024
1 parent cc432c4 commit a5bba88
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions vocabsieve/ui/main_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .multi_definition_widget import MultiDefinitionWidget
from .word_record_display import WordRecordDisplay

from ..global_names import app_title, settings, datapath, MOD
from ..global_names import app_title, settings, datapath, MOD, logger

from ..record import Record
from ..local_dictionary import LocalDictionary
Expand All @@ -20,7 +20,7 @@

import platform
import os
from sentence_splitter import SentenceSplitter
from sentence_splitter import SentenceSplitter, SentenceSplitterException
from pynput import keyboard


Expand All @@ -38,7 +38,11 @@ def __init__(self) -> None:
self.settings = settings
self.rec = Record(self.settings, datapath)
self.dictdb = LocalDictionary(datapath)
self.splitter = SentenceSplitter(language=self.settings.value("target_language", "en"))
try:
self.splitter = SentenceSplitter(language=self.settings.value("target_language", "en"))
except SentenceSplitterException:
logger.error("Sentence splitter failed to initialize. Falling back to English.")
self.splitter = SentenceSplitter(language="en")
self.setCentralWidget(self.widget)
self.previousWord = ""
self.audio_path = ""
Expand Down

0 comments on commit a5bba88

Please sign in to comment.