Teapack1 commited on
Commit
99f6b82
1 Parent(s): b44551d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -1,18 +1,23 @@
1
- from transformers import pipeline
2
-
3
- model_id = "sanchit-gandhi/distilhubert-finetuned-gtzan"
4
- pipe = pipeline("audio-classification", model=model_id)
5
 
6
- def classify_audio(filepath):
7
- preds = pipe(filepath)
8
- outputs = {}
9
- for p in preds:
10
- outputs[p["label"]] = p["score"]
11
- return outputs
12
 
13
- import gradio as gr
 
 
 
 
14
 
15
- demo = gr.Interface(
16
- fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label()
 
 
17
  )
 
 
 
 
 
 
 
18
  demo.launch(debug=True)
 
1
+ import gradio as gr
 
 
 
2
 
3
+ demo = gr.Blocks()
 
 
 
 
 
4
 
5
+ mic_transcribe = gr.Interface(
6
+ fn=transcribe_speech,
7
+ inputs=gr.Audio(sources="microphone", type="filepath"),
8
+ outputs=gr.outputs.Textbox(),
9
+ )
10
 
11
+ file_transcribe = gr.Interface(
12
+ fn=transcribe_speech,
13
+ inputs=gr.Audio(sources="upload", type="filepath"),
14
+ outputs=gr.outputs.Textbox(),
15
  )
16
+
17
+ with demo:
18
+ gr.TabbedInterface(
19
+ [mic_transcribe, file_transcribe],
20
+ ["Transcribe Microphone", "Transcribe Audio File"],
21
+ )
22
+
23
  demo.launch(debug=True)