added API compliance to the provider
This commit is contained in:
6
app.py
6
app.py
@@ -113,7 +113,11 @@ def main():
|
|||||||
saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filename)
|
saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filename)
|
||||||
saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filenamePdf)
|
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],
|
||||||
|
)
|
||||||
|
|
||||||
# Если пайплайн включен то тогда делаем автоматически
|
# Если пайплайн включен то тогда делаем автоматически
|
||||||
# автоматический пайплайн
|
# автоматический пайплайн
|
||||||
|
|||||||
@@ -11,14 +11,22 @@ class GradioHandlers:
|
|||||||
self.FasterWhisper = FasterWhisper()
|
self.FasterWhisper = FasterWhisper()
|
||||||
self.llm_factory = llm_factory # Сохраняем фабрику
|
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)
|
audioFile = self.ga.glue(audioFiles)
|
||||||
file = self.fh.saveFile(filename, audioFile, outPath)
|
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)
|
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:
|
try:
|
||||||
# Получаем нужный провайдер через фабрику
|
# Получаем нужный провайдер через фабрику
|
||||||
provider = self.llm_factory(llm_provider, api_key)
|
provider = self.llm_factory(llm_provider, api_key)
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
from faster_whisper import WhisperModel
|
from faster_whisper import WhisperModel
|
||||||
|
|
||||||
class FasterWhisper:
|
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) # Задаем модель
|
model = WhisperModel(model, device=device, compute_type=compute_type) # Задаем модель
|
||||||
|
|
||||||
segments, _ = model.transcribe( # Распознаем текст
|
segments, _ = model.transcribe( # Распознаем текст
|
||||||
|
|||||||
Reference in New Issue
Block a user