Futuresony commited on
Commit
f4cd8f2
Β·
verified Β·
1 Parent(s): 3fc3ef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -26
app.py CHANGED
@@ -1,32 +1,9 @@
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()
 
1
 
 
2
  import gradio as gr
 
3
 
4
+ whisper = gr.load("Futuresony/whisper-small-sw")
 
5
 
 
6
  def transcribe(audio):
7
+ return whisper(audio).replace("AutomaticSpeechRecognitionOutput(text=' ", "").replace("', chunks=None)", "")
 
 
 
 
8
 
9
+ gr.Interface(transcribe, gr.Audio(type="filepath"), gr.Textbox()).launch()