Nabeelbhat commited on
Commit
be1bfa1
·
verified ·
1 Parent(s): deda20e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import pipeline
3
+ import gradio as gr
4
+ def transcript_audio(audio_file):
5
+ # Initialize the speech recognition pipeline
6
+ pipe = pipeline(
7
+ "automatic-speech-recognition",
8
+ model="openai/whisper-tiny.en",
9
+ chunk_length_s=30,
10
+ )
11
+ # Transcribe the audio file and return the result
12
+ result = pipe(audio_file, batch_size=8)["text"]
13
+ return result
14
+ audio_input = gr.Audio(sources="upload", type="filepath") # Audio input
15
+ output_text = gr.Textbox() # Text output
16
+
17
+ iface = gr.Interface(fn=transcript_audio,
18
+ inputs=audio_input, outputs=output_text,
19
+ title="Title: Audio Transcription App - Created by Nabeel",
20
+ description="Upload the audio file")
21
+
22
+ iface.launch(server_name="0.0.0.0", server_port=7860,share=True)