Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
subprocess.run(["pip", "install", "whisper"])
|
3 |
+
subprocess.run(["pip", "install", "gradio", "--upgrade"])
|
4 |
+
subprocess.run(["pip", "install", "pip", "--upgrade"])
|
5 |
+
|
6 |
+
|
7 |
+
import gradio as gr
|
8 |
+
|
9 |
+
|
10 |
+
import whisper
|
11 |
+
|
12 |
+
def transcribe_audio(audio_file):
|
13 |
+
model = whisper.load_model("base")
|
14 |
+
result = model.transcribe(audio_file)
|
15 |
+
return result["text"]
|
16 |
+
|
17 |
+
|
18 |
+
def main():
|
19 |
+
audio_input = gr.inputs.Audio(source="upload", type="filepath")
|
20 |
+
output_text = gr.outputs.Textbox()
|
21 |
+
|
22 |
+
iface = gr.Interface(fn=transcribe_audio, inputs=audio_input,
|
23 |
+
outputs=output_text, title="Audio Transcription App",
|
24 |
+
description="Upload an audio file and hit the 'Submit'\
|
25 |
+
button")
|
26 |
+
|
27 |
+
iface.launch()
|
28 |
+
|
29 |
+
|
30 |
+
if __name__ == '__main__':
|
31 |
+
main()
|