diff --git a/app.py b/app.py index d4a29e2..6dda7f7 100644 --- a/app.py +++ b/app.py @@ -113,7 +113,11 @@ def main(): saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filename) saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filenamePdf) - recognizeBtn.click(gh.handleRecognizeBtn, outputs=[recognizedText], inputs=[audioFiles, fastWhisperModel, device, compute_type, beamSize, vadFilter, minSilenceDurationMs, speechPadMs, temp0, temp1, temp2, wordTimestamps, noSpeechThreshold, conditionOnPreviousText, gr.State(GLUED_AUDIO_FILENAME), gr.State(OUTPUT_PATH)]) + recognizeBtn.click( + gh.handleRecognizeBtn, + inputs=[audioFiles, fastWhisperModel, device, compute_type, beamSize, vadFilter, minSilenceDurationMs, speechPadMs, temp0, temp1, temp2, wordTimestamps, noSpeechThreshold, conditionOnPreviousText, gr.State(GLUED_AUDIO_FILENAME), gr.State(OUTPUT_PATH)], + outputs=[recognizedText], + ) # Если пайплайн включен то тогда делаем автоматически # автоматический пайплайн diff --git a/handlers/gradioHandler.py b/handlers/gradioHandler.py index aa5120c..1615377 100644 --- a/handlers/gradioHandler.py +++ b/handlers/gradioHandler.py @@ -11,14 +11,22 @@ class GradioHandlers: self.FasterWhisper = FasterWhisper() self.llm_factory = llm_factory # Сохраняем фабрику - def handleRecognizeBtn(self, audioFiles, model, device, compute_type, beamSize, vadFilter, minSilenceDurationMs, speechPadMs, temp0, temp1, temp2, wordTimestamps, noSpeechThreshold, conditionOnPreviousText, filename, outPath): + def handleRecognizeBtn( + self, audioFiles, model, device, + compute_type, beamSize, vadFilter, + minSilenceDurationMs, speechPadMs, + temp0, temp1, temp2, + wordTimestamps, noSpeechThreshold, conditionOnPreviousText, + filename, outPath): audioFile = self.ga.glue(audioFiles) file = self.fh.saveFile(filename, audioFile, outPath) - return self.FasterWhisper.recognize(model, device, compute_type, file, beamSize, vadFilter, minSilenceDurationMs, speechPadMs, temp0, temp1, temp2, wordTimestamps, noSpeechThreshold, conditionOnPreviousText) # Функция улучшения текста - def generateByCondition(self, api_key, llm_provider, llm_model, system_prompt, recognized_text, llm_temperature, is_pipeline_enabled, trigger, isSaveFile, filename, filenamePdf, output_path): + def generateByCondition(self, api_key, llm_provider, + llm_model, system_prompt, recognized_text, + llm_temperature, is_pipeline_enabled, trigger, + isSaveFile, filename, filenamePdf, output_path): try: # Получаем нужный провайдер через фабрику provider = self.llm_factory(llm_provider, api_key) diff --git a/services/fasterWhisper.py b/services/fasterWhisper.py index 7e32d52..67689af 100644 --- a/services/fasterWhisper.py +++ b/services/fasterWhisper.py @@ -1,7 +1,11 @@ from faster_whisper import WhisperModel class FasterWhisper: - def recognize(self, model, device, compute_type, audioFile, beamSize, vadFilter, minSilenceDurationMs, speechPadMs, temp0, temp1, temp2, wordTimestamps, noSpeechThreshold, conditionOnPreviousText): + def recognize(self, model, device, compute_type, + audioFile, beamSize, vadFilter, + minSilenceDurationMs, speechPadMs, + temp0, temp1, temp2, wordTimestamps, + noSpeechThreshold, conditionOnPreviousText): model = WhisperModel(model, device=device, compute_type=compute_type) # Задаем модель segments, _ = model.transcribe( # Распознаем текст