Teapack1 commited on
Commit
9226479
1 Parent(s): a7a91bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -21
app.py CHANGED
@@ -9,30 +9,18 @@ pipe = pipeline("audio-classification", model=model_id)
9
  title = "Keyword Spotting Wav2Vec2"
10
  description = "Gradio demo for finetuned Wav2Vec2 model on a custom dataset to perform keyword spotting task. Classes are scene 1, scene 2, scene 3, yes, no and stop."
11
 
12
- def classify_audio(filepath):
13
- preds = pipe(filepath,
14
- chunk_length_s=1,
15
- )
16
- outputs = {}
17
- for p in preds:
18
- outputs[p["label"]] = p["score"]
19
- return outputs
20
 
 
 
 
 
21
 
22
- demo = gr.Blocks()
23
-
24
- mic_classify = gr.Interface(
25
- title = title,
26
- description=description,
27
  fn=classify_audio,
28
- inputs=gr.Audio(sources="microphone", type="filepath"),
29
- outputs=gr.outputs.Label()
 
 
30
  )
31
 
32
-
33
- with demo:
34
- gr.TabbedInterface(
35
- [mic_classify, file_classify],
36
- ["Transcribe Microphone", "Transcribe Audio File"],
37
- )
38
  demo.launch(debug=True, share=True)
 
9
  title = "Keyword Spotting Wav2Vec2"
10
  description = "Gradio demo for finetuned Wav2Vec2 model on a custom dataset to perform keyword spotting task. Classes are scene 1, scene 2, scene 3, yes, no and stop."
11
 
 
 
 
 
 
 
 
 
12
 
13
+ def classify_audio(audio):
14
+ predictions = audio_classifier(audio)
15
+ return predictions
16
+
17
 
18
+ demo = gr.Interface(
 
 
 
 
19
  fn=classify_audio,
20
+ inputs=gr.inputs.Audio(source="microphone", type="numpy", label="Record your audio"),
21
+ outputs="label",
22
+ title="Audio Classification Demo",
23
+ description="A simple demo to classify audio using a Hugging Face model."
24
  )
25
 
 
 
 
 
 
 
26
  demo.launch(debug=True, share=True)