🚧[WIP/TEST] Model : 文字起こし起動時にエンジンを選択するように変更

This commit is contained in:
misyaguziya
2024-02-13 23:20:14 +09:00
parent 5a0c6392e0
commit 07b3c92f1b
2 changed files with 8 additions and 4 deletions

View File

@@ -341,6 +341,7 @@ class Model:
source=self.mic_audio_recorder.source, source=self.mic_audio_recorder.source,
phrase_timeout=phase_timeout, phrase_timeout=phase_timeout,
max_phrases=config.INPUT_MIC_MAX_PHRASES, max_phrases=config.INPUT_MIC_MAX_PHRASES,
transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE,
root=config.PATH_LOCAL, root=config.PATH_LOCAL,
whisper_weight_type=config.WHISPER_WEIGHT_TYPE, whisper_weight_type=config.WHISPER_WEIGHT_TYPE,
) )
@@ -443,6 +444,7 @@ class Model:
source=self.speaker_audio_recorder.source, source=self.speaker_audio_recorder.source,
phrase_timeout=phase_timeout, phrase_timeout=phase_timeout,
max_phrases=config.INPUT_SPEAKER_MAX_PHRASES, max_phrases=config.INPUT_SPEAKER_MAX_PHRASES,
transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE,
root=config.PATH_LOCAL, root=config.PATH_LOCAL,
whisper_weight_type=config.WHISPER_WEIGHT_TYPE, whisper_weight_type=config.WHISPER_WEIGHT_TYPE,
) )

View File

@@ -14,13 +14,15 @@ PHRASE_TIMEOUT = 3
MAX_PHRASES = 10 MAX_PHRASES = 10
class AudioTranscriber: 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.speaker = speaker
self.phrase_timeout = phrase_timeout self.phrase_timeout = phrase_timeout
self.max_phrases = max_phrases self.max_phrases = max_phrases
self.transcript_data = [] self.transcript_data = []
self.transcript_changed_event = Event() self.transcript_changed_event = Event()
self.audio_recognizer = Recognizer() self.audio_recognizer = Recognizer()
self.transcription_engine = "Google"
self.whisper_model = None
self.audio_sources = { self.audio_sources = {
"sample_rate": source.SAMPLE_RATE, "sample_rate": source.SAMPLE_RATE,
"sample_width": source.SAMPLE_WIDTH, "sample_width": source.SAMPLE_WIDTH,
@@ -30,10 +32,10 @@ class AudioTranscriber:
"new_phrase": True, "new_phrase": True,
"process_data_func": self.processSpeakerData if speaker else self.processSpeakerData "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) self.whisper_model = getWhisperModel(root, whisper_weight_type)
else: self.transcription_engine = "Whisper"
self.whisper_model = None
def transcribeAudioQueue(self, audio_queue, language, country, transcription_engine): def transcribeAudioQueue(self, audio_queue, language, country, transcription_engine):
audio, time_spoken = audio_queue.get() audio, time_spoken = audio_queue.get()