Introduce dataclasses for configuring model settings
This commit is contained in:
@@ -49,26 +49,29 @@ class STTBox(Gtk.Box):
|
||||
self.add(self._transcribe_button)
|
||||
self.add(self._transcription_label)
|
||||
|
||||
self._result = helper.Results('')
|
||||
|
||||
self._transcribe_button.connect('clicked', self._on_transcribe_clicked)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def _on_transcribe_clicked(self, _button: Gtk.Button) -> None:
|
||||
log.debug('config.data = %s', self._config.data)
|
||||
model_class = self._config.data['model_class']
|
||||
if model_class is None:
|
||||
model = self._config.data['model_instance']
|
||||
if model is None:
|
||||
return
|
||||
|
||||
self._model = model_class()
|
||||
self._model = model
|
||||
|
||||
transcription_task = helper.BackgroundTask(
|
||||
self._model.transcribe(self._audio_file),
|
||||
self._model.transcribe(self._result, self._audio_file),
|
||||
self._show_result
|
||||
)
|
||||
transcription_task.start()
|
||||
|
||||
def _show_result(self):
|
||||
self._text = self._model.result
|
||||
assert self._model is not None
|
||||
self._text = self._result.text
|
||||
if self._text.strip() != '':
|
||||
self._transcription_label.set_text(self._text.strip())
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user