From 07b3c92f1b74dc1805af3f7cc8a64212a41b0346 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Tue, 13 Feb 2024 23:20:14 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7[WIP/TEST]=20Model=20:=20=E6=96=87?= =?UTF-8?q?=E5=AD=97=E8=B5=B7=E3=81=93=E3=81=97=E8=B5=B7=E5=8B=95=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3=E3=82=92=E9=81=B8?= =?UTF-8?q?=E6=8A=9E=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model.py | 2 ++ models/transcription/transcription_transcriber.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/model.py b/model.py index 6bc62b0c..e68c01bc 100644 --- a/model.py +++ b/model.py @@ -341,6 +341,7 @@ class Model: source=self.mic_audio_recorder.source, phrase_timeout=phase_timeout, max_phrases=config.INPUT_MIC_MAX_PHRASES, + transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE, root=config.PATH_LOCAL, whisper_weight_type=config.WHISPER_WEIGHT_TYPE, ) @@ -443,6 +444,7 @@ class Model: source=self.speaker_audio_recorder.source, phrase_timeout=phase_timeout, max_phrases=config.INPUT_SPEAKER_MAX_PHRASES, + transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE, root=config.PATH_LOCAL, whisper_weight_type=config.WHISPER_WEIGHT_TYPE, ) diff --git a/models/transcription/transcription_transcriber.py b/models/transcription/transcription_transcriber.py index 08cc6a1a..35f79c43 100644 --- a/models/transcription/transcription_transcriber.py +++ b/models/transcription/transcription_transcriber.py @@ -14,13 +14,15 @@ PHRASE_TIMEOUT = 3 MAX_PHRASES = 10 class AudioTranscriber: - def __init__(self, speaker, source, phrase_timeout, max_phrases, root=None, whisper_weight_type=None, ): + def __init__(self, speaker, source, phrase_timeout, max_phrases, transcription_engine, root=None, whisper_weight_type=None): self.speaker = speaker self.phrase_timeout = phrase_timeout self.max_phrases = max_phrases self.transcript_data = [] self.transcript_changed_event = Event() self.audio_recognizer = Recognizer() + self.transcription_engine = "Google" + self.whisper_model = None self.audio_sources = { "sample_rate": source.SAMPLE_RATE, "sample_width": source.SAMPLE_WIDTH, @@ -30,10 +32,10 @@ class AudioTranscriber: "new_phrase": True, "process_data_func": self.processSpeakerData if speaker else self.processSpeakerData } - if whisper_weight_type is not None and root is not None and checkWhisperWeight(root, whisper_weight_type) is True: + + if transcription_engine == "Whisper" and checkWhisperWeight(root, whisper_weight_type) is True: self.whisper_model = getWhisperModel(root, whisper_weight_type) - else: - self.whisper_model = None + self.transcription_engine = "Whisper" def transcribeAudioQueue(self, audio_queue, language, country, transcription_engine): audio, time_spoken = audio_queue.get()