Kalp97 commited on
Commit
63008ca
·
verified ·
1 Parent(s): 3fd956c

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import whisper
3
+ import os
4
+ import tempfile
5
+
6
+ model = None
7
+
8
+ def load_model():
9
+ global model
10
+ if model is None:
11
+ model = whisper.load_model("base")
12
+ return model
13
+
14
+ def transcribe(file):
15
+ if file is None:
16
+ return "Please upload a video or audio file."
17
+
18
+ try:
19
+ m = load_model()
20
+ result = m.transcribe(file, language="en", verbose=False)
21
+ transcript = result["text"].strip()
22
+ return transcript
23
+ except Exception as e:
24
+ return f"Error: {str(e)}"
25
+
26
+ demo = gr.Interface(
27
+ fn=transcribe,
28
+ inputs=gr.Audio(type="filepath", label="Upload your video or audio file"),
29
+ outputs=gr.Textbox(label="Transcript", lines=15, show_copy_button=True),
30
+ title="🎙️ AI Video Transcriber",
31
+ description="Upload any video or audio file and get a full transcript powered by OpenAI Whisper.",
32
+ examples=[],
33
+ theme=gr.themes.Soft()
34
+ )
35
+
36
+ if __name__ == "__main__":
37
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ openai-whisper
3
+ ffmpeg-python