add right run style
This commit is contained in:
178
app.py
178
app.py
@@ -14,105 +14,109 @@ from handlers.convertMdToPdf import ConvertMdToPdf
|
|||||||
|
|
||||||
gh = GradioHandlers(gr, Llm, ConvertMdToPdf, FileHandlers, FasterWhisper)
|
gh = GradioHandlers(gr, Llm, ConvertMdToPdf, FileHandlers, FasterWhisper)
|
||||||
|
|
||||||
with gr.Blocks() as demo:
|
def main():
|
||||||
gr.HTML('''
|
with gr.Blocks() as demo:
|
||||||
<div align=center>
|
gr.HTML('''
|
||||||
<h1>
|
<div align=center>
|
||||||
Faster Whisper WebUI
|
<h1>
|
||||||
</h1>
|
Faster Whisper WebUI
|
||||||
</div>
|
</h1>
|
||||||
''')
|
</div>
|
||||||
|
''')
|
||||||
|
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
# Вкладка с основным взаимодействием
|
# Вкладка с основным взаимодействием
|
||||||
with gr.Tab('Actions'):
|
with gr.Tab('Actions'):
|
||||||
isPipelineEnabledCheckbox = gr.Checkbox(label='is pipeline enabled', value=True, interactive=True)
|
isPipelineEnabledCheckbox = gr.Checkbox(label='is pipeline enabled', value=True, interactive=True)
|
||||||
|
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
with gr.Accordion(label='Recognization and integration'):
|
with gr.Accordion(label='Recognization and integration'):
|
||||||
with gr.Column():
|
|
||||||
audioFile = gr.Audio(label='Load audio for transcribe', type="filepath")
|
|
||||||
images = gr.Files(label='Upload images', file_types=['image'])
|
|
||||||
recognizeBtn = gr.Button('recognize and integrate', variant='primary')
|
|
||||||
|
|
||||||
with gr.Accordion(label='Recognized text'):
|
|
||||||
recognizedText = gr.TextArea(label='')
|
|
||||||
|
|
||||||
with gr.Accordion(label='LLM'):
|
|
||||||
with gr.Column():
|
|
||||||
refineTextBtn = gr.Button('refine text', variant='secondary', interactive=False)
|
|
||||||
|
|
||||||
with gr.Accordion(label='Refined text raw'):
|
|
||||||
refinedText = gr.Textbox(label='', show_copy_button=True)
|
|
||||||
|
|
||||||
with gr.Accordion(label='Refined text md formated'):
|
|
||||||
refinedTextMD = gr.Markdown(label='')
|
|
||||||
|
|
||||||
# Вкладка с настройками
|
|
||||||
with gr.Tab('Settings'):
|
|
||||||
with gr.Column():
|
|
||||||
# Первое поле на всю ширину в акордионе настроек
|
|
||||||
with gr.Accordion('File settings'):
|
|
||||||
saveFileCheckbox = gr.Checkbox(label='save file', value=True, interactive=True)
|
|
||||||
filename = gr.Textbox(label='Output filename', value='output.txt', interactive=True)
|
|
||||||
filenamePdf = gr.Textbox(label='Output filename for pdf', value='output.pdf', interactive=True)
|
|
||||||
|
|
||||||
# Акордион настроек faster whisper
|
|
||||||
with gr.Accordion(label='Faster whisper settings'):
|
|
||||||
with gr.Row():
|
|
||||||
# Левая колонка в акордионе
|
|
||||||
with gr.Column():
|
with gr.Column():
|
||||||
device = gr.Dropdown(label='Device', choices=DEVICES, value=DEVICES[1], interactive=True)
|
audioFile = gr.Audio(label='Load audio for transcribe', type="filepath")
|
||||||
compute_type = gr.Dropdown(label='compute_type', choices=COMPUTE_TYPE, value=COMPUTE_TYPE[0], interactive=True)
|
images = gr.Files(label='Upload images', file_types=['image'])
|
||||||
fastWhisperModel = gr.Dropdown(label='Model', choices=FAST_WHISPER_MODELS, value=FAST_WHISPER_MODELS[11], interactive=True)
|
recognizeBtn = gr.Button('recognize and integrate', variant='primary')
|
||||||
|
|
||||||
beamSize = gr.Number(label='beam_size', value=8, interactive=True)
|
with gr.Accordion(label='Recognized text'):
|
||||||
noSpeechThreshold = gr.Number(label='no_speech_threshold', value=0.5, interactive=True)
|
recognizedText = gr.TextArea(label='')
|
||||||
vadFilter = gr.Checkbox(label='vad_filter', value=True, interactive=True)
|
|
||||||
wordTimestamps = gr.Checkbox(label='word_timestamps', value=True, interactive=True)
|
|
||||||
conditionOnPreviousText = gr.Checkbox(label='condition_on_previous_text', value=False, interactive=True)
|
|
||||||
|
|
||||||
# Правая колонка в акордионе
|
with gr.Accordion(label='LLM'):
|
||||||
with gr.Column():
|
with gr.Column():
|
||||||
with gr.Accordion(label='Vad parameters'):
|
refineTextBtn = gr.Button('refine text', variant='secondary', interactive=False)
|
||||||
minSilenceDurationMs = gr.Number(label='min_silence_duration_ms', value=300, interactive=True)
|
|
||||||
speechPadMs = gr.Number(label='speech_pad_ms', value=200, interactive=True)
|
|
||||||
|
|
||||||
with gr.Accordion(label='Temperature'):
|
with gr.Accordion(label='Refined text raw'):
|
||||||
temp0 = gr.Number(label='temp_0', value=0.0, interactive=True)
|
refinedText = gr.Textbox(label='', show_copy_button=True)
|
||||||
temp1 = gr.Number(label='temp_1', value=0.2, interactive=True)
|
|
||||||
temp2 = gr.Number(label='temp_2', value=0.4, interactive=True)
|
|
||||||
|
|
||||||
# Нижний акордион настроек для api ключа llm
|
with gr.Accordion(label='Refined text md formated'):
|
||||||
with gr.Accordion(label='ai.io.net api settings'):
|
refinedTextMD = gr.Markdown(label='')
|
||||||
apiKey = gr.Textbox(label='API key', value=DEFAULT_API_KEY, interactive=True)
|
|
||||||
|
|
||||||
with gr.Accordion(label='System prompt'):
|
# Вкладка с настройками
|
||||||
systemPrompt = gr.Textbox(label='', value=DEFAULT_SYSTEM_PROMPT, interactive=True)
|
with gr.Tab('Settings'):
|
||||||
|
with gr.Column():
|
||||||
|
# Первое поле на всю ширину в акордионе настроек
|
||||||
|
with gr.Accordion('File settings'):
|
||||||
|
saveFileCheckbox = gr.Checkbox(label='save file', value=True, interactive=True)
|
||||||
|
filename = gr.Textbox(label='Output filename', value='output.txt', interactive=True)
|
||||||
|
filenamePdf = gr.Textbox(label='Output filename for pdf', value='output.pdf', interactive=True)
|
||||||
|
|
||||||
with gr.Row():
|
# Акордион настроек faster whisper
|
||||||
llmModel = gr.Dropdown(label='models', choices=LLM_MODELS, value=LLM_MODELS[1], interactive=True)
|
with gr.Accordion(label='Faster whisper settings'):
|
||||||
llmTemperature = gr.Number(label='Temperature', value=0.8, interactive=True )
|
with gr.Row():
|
||||||
|
# Левая колонка в акордионе
|
||||||
|
with gr.Column():
|
||||||
|
device = gr.Dropdown(label='Device', choices=DEVICES, value=DEVICES[1], interactive=True)
|
||||||
|
compute_type = gr.Dropdown(label='compute_type', choices=COMPUTE_TYPE, value=COMPUTE_TYPE[0], interactive=True)
|
||||||
|
fastWhisperModel = gr.Dropdown(label='Model', choices=FAST_WHISPER_MODELS, value=FAST_WHISPER_MODELS[11], interactive=True)
|
||||||
|
|
||||||
isPipelineEnabledCheckbox.change(gh.updateButton, inputs=[isPipelineEnabledCheckbox], outputs=refineTextBtn)
|
beamSize = gr.Number(label='beam_size', value=8, interactive=True)
|
||||||
saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filename)
|
noSpeechThreshold = gr.Number(label='no_speech_threshold', value=0.5, interactive=True)
|
||||||
saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filenamePdf)
|
vadFilter = gr.Checkbox(label='vad_filter', value=True, interactive=True)
|
||||||
|
wordTimestamps = gr.Checkbox(label='word_timestamps', value=True, interactive=True)
|
||||||
|
conditionOnPreviousText = gr.Checkbox(label='condition_on_previous_text', value=False, interactive=True)
|
||||||
|
|
||||||
recognizeBtn.click(gh.FasterWhisper.recognize, outputs=[recognizedText], inputs=[fastWhisperModel, device, compute_type, audioFile, beamSize, vadFilter, minSilenceDurationMs, speechPadMs, temp0, temp1, temp2, wordTimestamps, noSpeechThreshold, conditionOnPreviousText])
|
# Правая колонка в акордионе
|
||||||
|
with gr.Column():
|
||||||
|
with gr.Accordion(label='Vad parameters'):
|
||||||
|
minSilenceDurationMs = gr.Number(label='min_silence_duration_ms', value=300, interactive=True)
|
||||||
|
speechPadMs = gr.Number(label='speech_pad_ms', value=200, interactive=True)
|
||||||
|
|
||||||
# Если пайплайн включен то тогда делаем автоматически
|
with gr.Accordion(label='Temperature'):
|
||||||
# автоматический пайплайн
|
temp0 = gr.Number(label='temp_0', value=0.0, interactive=True)
|
||||||
recognizedText.change(
|
temp1 = gr.Number(label='temp_1', value=0.2, interactive=True)
|
||||||
gh.generateByCondition,
|
temp2 = gr.Number(label='temp_2', value=0.4, interactive=True)
|
||||||
inputs=[apiKey, llmModel, systemPrompt, recognizedText, llmTemperature, isPipelineEnabledCheckbox, gr.State("change"), saveFileCheckbox, filename, filenamePdf, gr.State(OUTPUT_PATH)],
|
|
||||||
outputs=[refinedText, refinedTextMD]
|
|
||||||
)
|
|
||||||
|
|
||||||
# ручной запуск по кнопке
|
# Нижний акордион настроек для api ключа llm
|
||||||
refineTextBtn.click(
|
with gr.Accordion(label='ai.io.net api settings'):
|
||||||
gh.generateByCondition,
|
apiKey = gr.Textbox(label='API key', value=DEFAULT_API_KEY, interactive=True)
|
||||||
inputs=[apiKey, llmModel, systemPrompt, recognizedText, llmTemperature, isPipelineEnabledCheckbox, gr.State("click"), saveFileCheckbox, filename, filenamePdf, gr.State(OUTPUT_PATH)],
|
|
||||||
outputs=[refinedText, refinedTextMD]
|
|
||||||
)
|
|
||||||
|
|
||||||
demo.launch()
|
with gr.Accordion(label='System prompt'):
|
||||||
|
systemPrompt = gr.Textbox(label='', value=DEFAULT_SYSTEM_PROMPT, interactive=True)
|
||||||
|
|
||||||
|
with gr.Row():
|
||||||
|
llmModel = gr.Dropdown(label='models', choices=LLM_MODELS, value=LLM_MODELS[1], interactive=True)
|
||||||
|
llmTemperature = gr.Number(label='Temperature', value=0.8, interactive=True )
|
||||||
|
|
||||||
|
isPipelineEnabledCheckbox.change(gh.updateButton, inputs=[isPipelineEnabledCheckbox], outputs=refineTextBtn)
|
||||||
|
saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filename)
|
||||||
|
saveFileCheckbox.change(gh.updateTextbox, inputs=saveFileCheckbox, outputs=filenamePdf)
|
||||||
|
|
||||||
|
recognizeBtn.click(gh.FasterWhisper.recognize, outputs=[recognizedText], inputs=[fastWhisperModel, device, compute_type, audioFile, beamSize, vadFilter, minSilenceDurationMs, speechPadMs, temp0, temp1, temp2, wordTimestamps, noSpeechThreshold, conditionOnPreviousText])
|
||||||
|
|
||||||
|
# Если пайплайн включен то тогда делаем автоматически
|
||||||
|
# автоматический пайплайн
|
||||||
|
recognizedText.change(
|
||||||
|
gh.generateByCondition,
|
||||||
|
inputs=[apiKey, llmModel, systemPrompt, recognizedText, llmTemperature, isPipelineEnabledCheckbox, gr.State("change"), saveFileCheckbox, filename, filenamePdf, gr.State(OUTPUT_PATH)],
|
||||||
|
outputs=[refinedText, refinedTextMD]
|
||||||
|
)
|
||||||
|
|
||||||
|
# ручной запуск по кнопке
|
||||||
|
refineTextBtn.click(
|
||||||
|
gh.generateByCondition,
|
||||||
|
inputs=[apiKey, llmModel, systemPrompt, recognizedText, llmTemperature, isPipelineEnabledCheckbox, gr.State("click"), saveFileCheckbox, filename, filenamePdf, gr.State(OUTPUT_PATH)],
|
||||||
|
outputs=[refinedText, refinedTextMD]
|
||||||
|
)
|
||||||
|
|
||||||
|
demo.launch()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user