juliensimon HF staff commited on
Commit
e130e80
1 Parent(s): 7806254

Initial version

Browse files
Files changed (8) hide show
  1. app.py +40 -0
  2. backward16k.wav +0 -0
  3. happy16k.wav +0 -0
  4. marvin16k.wav +0 -0
  5. requirements.txt +3 -0
  6. seven16k.wav +0 -0
  7. stop16k.wav +0 -0
  8. up16k.wav +0 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ model_name = "juliensimon/wav2vec2-conformer-rel-pos-large-finetuned-speech-commands"
5
+
6
+ p = pipeline("audio-classification", model=model_name)
7
+
8
+ def process(file):
9
+ pred = p(file)
10
+ labels = dict()
11
+ for l in pred:
12
+ labels[l['label']]=l['score']
13
+ return labels
14
+
15
+ # Gradio inputs
16
+ mic = gr.inputs.Audio(source='microphone', type='filepath', label='Speech input', optional=True)
17
+
18
+ # Gradio outputs
19
+ keyword = gr.outputs.Label(num_top_classes=3)
20
+
21
+ description = "This Space showcases a wav2vec2-conformer-rel-pos-large model fine-tuned for audio classification on the speech_commands dataset. \n \n It can spot one of the following keywords: 'Yes', 'No', 'Up', 'Down', 'Left', 'Right', 'On', 'Off', 'Stop', 'Go', 'Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Bed', 'Bird', 'Cat', 'Dog', 'Happy', 'House', 'Marvin', 'Sheila', 'Tree', 'Wow', 'Backward', 'Forward', 'Follow', 'Learn', 'Visual'."
22
+
23
+ iface = gr.Interface(
24
+ theme='huggingface',
25
+ description=description,
26
+ fn=process,
27
+ layout='horizontal',
28
+ inputs=[mic],
29
+ outputs=[keyword],
30
+ examples=[
31
+ ['backward16k.wav'],
32
+ ['happy16k.wav'],
33
+ ['marvin16k.wav'],
34
+ ['seven16k.wav'],
35
+ ['stop16k.wav'],
36
+ ['up16k.wav'],
37
+ ],
38
+ allow_flagging=False
39
+ )
40
+ iface.launch()
backward16k.wav ADDED
Binary file (62.8 kB). View file
happy16k.wav ADDED
Binary file (56.7 kB). View file
marvin16k.wav ADDED
Binary file (38.9 kB). View file
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ torch
2
+ transformers
3
+ librosa
seven16k.wav ADDED
Binary file (37.6 kB). View file
stop16k.wav ADDED
Binary file (56.7 kB). View file
up16k.wav ADDED
Binary file (51.2 kB). View file