Spaces:
Sleeping
Sleeping
File size: 2,593 Bytes
2458f16 400c98c 2458f16 400c98c c67b30e 400c98c c67b30e 400c98c c67b30e 400c98c c67b30e 400c98c c67b30e 400c98c c67b30e 400c98c 68d07e5 c67b30e 400c98c c67b30e 400c98c c67b30e 400c98c c67b30e 400c98c c67b30e 68d07e5 c67b30e 400c98c 2458f16 c67b30e 2458f16 400c98c d257e00 2458f16 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import gradio as gr
from lib.config import (
AUDIO_DIR,
TRANSCRIPTS_DIR,
)
from lib.media import (
extract_audio_from_video,
save_file,
)
from lib.model import (
transcribe_audio,
)
# -->> Tunables <<---------------------
# -->> Definitions <<------------------
def interface_creation():
with gr.Blocks() as interface:
with gr.Row():
with gr.Column():
gr.Markdown("## Extract Audio from Video")
audio_inp = [
gr.Video(label="Upload Video"),
gr.Textbox(value=AUDIO_DIR, label="Output Audio Folder Path"),
]
audio_btn = gr.Button("Extract Audio")
with gr.Column():
gr.Markdown("### Extracted Audio from Video")
audio_out = [
gr.Audio(label="Extracted Audio"),
gr.Textbox(label="Audio Path"),
]
with gr.Row():
with gr.Column():
gr.Markdown("## Transcribe Audio")
transcribe_inp = [
gr.Audio(label="Upload Audio"),
gr.Textbox(label="Audio Path"),
gr.Textbox(
value=TRANSCRIPTS_DIR, label="Output Transcript Folder Path"
),
]
transcribe_btn = gr.Button("Transcribe Audio")
with gr.Column():
gr.Markdown("### Transcription:")
transcribe_out = gr.Textbox(label="Transcription")
download_btn = gr.Button("Download Transcript")
download_path = gr.Textbox(label="Download File Path")
download_link = gr.Textbox(label="Download Link")
audio_btn.click(
fn=extract_audio_from_video, inputs=audio_inp, outputs=audio_out
).then(
fn=lambda audio_file, audio_path: [audio_file, audio_path],
inputs=audio_out,
outputs=[transcribe_inp[0], transcribe_inp[1]],
)
transcribe_btn.click(
transcribe_audio, inputs=transcribe_inp, outputs=transcribe_out
)
download_btn.click(
save_file,
inputs=[transcribe_inp[1], transcribe_inp[2], transcribe_out],
outputs=[download_path, download_link]
)
return interface
# -->> API <<--------------------------
iface = interface_creation()
iface.launch()
# -->> Execute <<----------------------
# -->> Export <<-----------------------
|