bartelds commited on
Commit
49520fc
·
1 Parent(s): f0fa166

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -1,13 +1,25 @@
1
  # Code adapted from: https://gradio.app/demos/
2
 
3
  import gradio as gr
4
- import os
 
5
 
6
- demo = gr.Interface.load(
7
- "huggingface/bartelds/gos-gpu6-cp1_adp0_192m_no_test_1e-5_cp-12000",
 
 
 
 
 
 
 
 
 
 
 
 
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()