Spaces:
Runtime error
Runtime error
Commit ·
fa081e7
1
Parent(s): caa3c0d
Create asr_transcription.ipynb
Browse files- asr_transcription.ipynb +21 -0
asr_transcription.ipynb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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')
|
| 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 |
+
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn = transcribe,
|
| 17 |
+
inputs = gr.Audio(sources=['microphone']),
|
| 18 |
+
outputs = 'text',
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
demo.launch()
|