First steps to multi model plugin
This commit is contained in:
65
stt_voice_messages/gtk/sttbox.py
Normal file
65
stt_voice_messages/gtk/sttbox.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# This file is part of Gajim.
|
||||
#
|
||||
# Gajim is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Gajim is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
from pathlib import Path
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gajim.plugins.gajimplugin import GajimPluginConfig
|
||||
from gajim.plugins.plugins_i18n import _
|
||||
|
||||
from .. import helper
|
||||
|
||||
|
||||
class STTBox(Gtk.Box):
|
||||
def __init__(self,
|
||||
preview_audio_widget: Gtk.Box,
|
||||
config: GajimPluginConfig,
|
||||
audio_file: Path,
|
||||
) -> None:
|
||||
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
||||
|
||||
self._config = config
|
||||
self._preview_audio = preview_audio_widget
|
||||
self._model = None
|
||||
self._audio_file = audio_file
|
||||
self._text = ''
|
||||
|
||||
self._transcribe_button = Gtk.Button(label=_('Transcribe'))
|
||||
|
||||
self._transcription_label = Gtk.Label(label=_('Nothing transcribed yet'))
|
||||
self._transcription_label.set_max_width_chars(40)
|
||||
self._transcription_label.set_line_wrap(True)
|
||||
|
||||
self.add(self._transcribe_button)
|
||||
self.add(self._transcription_label)
|
||||
|
||||
self._transcribe_button.connect('clicked', self._on_transcribe_clicked)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def _on_transcribe_clicked(self, _button: Gtk.Button):
|
||||
#transcription_task = helper.BackgroundTask(
|
||||
# self._model.transcribe(),
|
||||
# self._show_result
|
||||
#)
|
||||
#transcription_task.start()
|
||||
pass
|
||||
|
||||
def _show_result(self):
|
||||
if self._text.strip() != '':
|
||||
self._transcription_label.set_text(self._text.strip())
|
||||
else:
|
||||
self._transcription_label.set_text(_('_Have not heard any word!_'))
|
||||
Reference in New Issue
Block a user