Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,25 @@
|
|
| 1 |
# Code adapted from: https://gradio.app/demos/
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
-
import
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
title="Speech-to-text for Gronings",
|
| 9 |
-
inputs="mic",
|
| 10 |
description="Upload an audio file (in 16 kHz) with Gronings speech to obtain its transcription. Example files are in our [gos-demo](https://huggingface.co/datasets/bartelds/gos-demo) dataset."
|
| 11 |
)
|
| 12 |
|
| 13 |
-
demo.launch()
|
|
|
|
| 1 |
# Code adapted from: https://gradio.app/demos/
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
import numpy as np
|
| 6 |
|
| 7 |
+
transcriber = pipeline("automatic-speech-recognition", model="bartelds/gos-gpu6-cp1_adp0_192m_no_test_1e-5_cp-12000")
|
| 8 |
+
|
| 9 |
+
def transcribe(audio):
|
| 10 |
+
sr, y = audio
|
| 11 |
+
y = y.astype(np.float32)
|
| 12 |
+
y /= np.max(np.abs(y))
|
| 13 |
+
|
| 14 |
+
return transcriber({"sampling_rate": sr, "raw": y})["text"]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
transcribe,
|
| 19 |
+
gr.Audio(source="upload"),
|
| 20 |
+
"text",
|
| 21 |
title="Speech-to-text for Gronings",
|
|
|
|
| 22 |
description="Upload an audio file (in 16 kHz) with Gronings speech to obtain its transcription. Example files are in our [gos-demo](https://huggingface.co/datasets/bartelds/gos-demo) dataset."
|
| 23 |
)
|
| 24 |
|
| 25 |
+
demo.launch()
|