akxier commited on
Commit
884e547
1 Parent(s): 629c823

Upload gr_iabd.py

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