wang0507 commited on
Commit
b685b14
·
1 Parent(s): 994e19d

Create app2.py

Browse files
Files changed (1) hide show
  1. app2.py +25 -0
app2.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ p = pipeline("automatic-speech-recognition", model="openai/whisper-base.ch")
4
+
5
+ import gradio as gr
6
+ from transformers import pipeline
7
+ import numpy as np
8
+
9
+ transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.ch")
10
+
11
+ def transcribe(audio):
12
+ sr, y = audio
13
+ y = y.astype(np.float32)
14
+ y /= np.max(np.abs(y))
15
+
16
+ return transcriber({"sampling_rate": sr, "raw": y})["text"]
17
+
18
+
19
+ demo = gr.Interface(
20
+ transcribe,
21
+ gr.Audio(sources=["microphone"]),
22
+ "text",
23
+ )
24
+
25
+ demo.launch()