Futuresony commited on
Commit
3c2fc1b
Β·
verified Β·
1 Parent(s): aeac8d9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Import necessary modules
3
+ import gradio as gr
4
+ from transformers import pipeline
5
+
6
+ # Load the fine-tuned model from Hugging Face
7
+ pipe = pipeline("automatic-speech-recognition", model="Futuresony/whisper-small-sw")
8
+
9
+ # Function to transcribe audio
10
+ def transcribe(audio):
11
+ if audio is None:
12
+ return "Please upload or record an audio file."
13
+ print("Transcribing audio...")
14
+ result = pipe(audio)["text"]
15
+ return result
16
+
17
+ # Gradio App
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("# πŸŽ™οΈ Swahili Speech-to-Text Transcription App")
20
+
21
+ with gr.Row():
22
+ audio_input = gr.Audio(source="microphone", type="filepath", label="🎀 Record Audio")
23
+ file_input = gr.Audio(source="upload", type="filepath", label="πŸ“‚ Upload Audio File")
24
+
25
+ transcribe_button = gr.Button("Transcribe")
26
+ output_text = gr.Textbox(label="πŸ“ Transcription Output")
27
+
28
+ transcribe_button.click(transcribe, inputs=[audio_input], outputs=output_text)
29
+ transcribe_button.click(transcribe, inputs=[file_input], outputs=output_text)
30
+
31
+ # Launch the app
32
+ demo.launch()