weijiang2024 commited on
Commit
0f3bac1
·
verified ·
1 Parent(s): a30d77b

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +5 -8
  2. app.py +20 -0
README.md CHANGED
@@ -1,12 +1,9 @@
1
  ---
2
- title: Suanfamama Speech Recognition Synthesis
3
- emoji: 🐢
4
- colorFrom: gray
5
- colorTo: green
6
- sdk: gradio
7
- sdk_version: 4.41.0
8
  app_file: app.py
9
- pinned: false
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: Suanfamama_Speech_Recognition_Synthesis
 
 
 
 
 
3
  app_file: app.py
4
+ sdk: gradio
5
+ sdk_version: 4.29.0
6
  ---
7
 
8
+ ## Reference
9
+ 1. Real Time Speech Recognition https://www.gradio.app/guides/real-time-speech-recognition
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(audio):
8
+ sr, y = audio
9
+ y = y.astype(np.float32)
10
+ y /= np.max(np.abs(y))
11
+
12
+ return transcriber({"sampling_rate": sr, "raw": y})["text"]
13
+
14
+ demo = gr.Interface(
15
+ transcribe,
16
+ gr.Audio(sources=["microphone"]),
17
+ "text",
18
+ )
19
+
20
+ demo.launch()