Scrapyard commited on
Commit
62adaaf
·
1 Parent(s): 218a8f6

testing if commit works

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -1,7 +1,30 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "plz change" + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  demo.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+ import numpy as np
4
 
5
+ transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
6
+
7
+ def transcribe(stream, new_chunk):
8
+ sr, y = new_chunk
9
+
10
+ # Convert to mono if stereo
11
+ if y.ndim > 1:
12
+ y = y.mean(axis=1)
13
+
14
+ y = y.astype(np.float32)
15
+ y /= np.max(np.abs(y))
16
+
17
+ if stream is not None:
18
+ stream = np.concatenate([stream, y])
19
+ else:
20
+ stream = y
21
+ return stream
22
+
23
+ demo = gr.Interface(
24
+ transcribe,
25
+ ["state", gr.Audio(sources=["microphone"], streaming=True)],
26
+ ["state", "text"],
27
+ live=True,
28
+ )
29
 
 
30
  demo.launch()