Scrapyard commited on
Commit
1a8ef5b
·
2 Parent(s): 91e4d97 62adaaf

Merge branch 'main' of https://huggingface.co/spaces/Scrapyard-Brampton/Testing

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -1,9 +1,32 @@
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()
8
 
9
  # transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
 
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()
31
 
32
  # transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")