Spaces:
Running
Running
V1
Browse files- Setup basic audio -> text pipeline
- Setup basic app interface
.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
REPLICATE_API_TOKEN = r8_2nj6fllJpzdNMAA3vo9pymmfhvqOqf00zGghp
|
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import replicate
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
REPLICATE_API_TOKEN = os.getenv("REPLICATE_API_TOKEN")
|
| 6 |
+
|
| 7 |
+
def process_audio(audio):
|
| 8 |
+
if audio is None:
|
| 9 |
+
return "No audio file uploaded."
|
| 10 |
+
output = replicate.run(
|
| 11 |
+
"victor-upmeet/whisperx:84d2ad2d6194fe98a17d2b60bef1c7f910c46b2f6fd38996ca457afd9c8abfcb",
|
| 12 |
+
input={"audio_file": open(audio, "rb")},
|
| 13 |
+
api_token=REPLICATE_API_TOKEN
|
| 14 |
+
)
|
| 15 |
+
segments = output.get("segments") if isinstance(output, dict) else output
|
| 16 |
+
|
| 17 |
+
script = " ".join(seg["text"] for seg in segments) if segments else output.get("text", "No transcription found.")
|
| 18 |
+
return script
|
| 19 |
+
|
| 20 |
+
with gr.Blocks(theme="monochrome") as demo:
|
| 21 |
+
gr.Markdown("# AIML430 Lecture Transcription Tool")
|
| 22 |
+
gr.Markdown("Upload an audio file to begin.")
|
| 23 |
+
audio_input = gr.Audio(type="filepath", sources=["upload"], label="Audio File")
|
| 24 |
+
raw_text_output = gr.Textbox(
|
| 25 |
+
label="Raw Text Output",
|
| 26 |
+
show_copy_button=True,
|
| 27 |
+
lines=10
|
| 28 |
+
)
|
| 29 |
+
audio_input.change(
|
| 30 |
+
fn=process_audio,
|
| 31 |
+
inputs=audio_input,
|
| 32 |
+
outputs=raw_text_output
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
demo.launch()
|