Spaces:
Runtime error
Runtime error
Commit
·
4644758
1
Parent(s):
d21488f
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- app.py +54 -0
- example.wav +0 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🦀
|
| 4 |
-
colorFrom: purple
|
| 5 |
-
colorTo: gray
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 3.38.0
|
| 8 |
app_file: app.py
|
| 9 |
-
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: automatic-speech-recognition-german
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
app_file: app.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.36.0
|
| 6 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
model_id = "openai/whisper-large-v2" # update with your model id
|
| 6 |
+
pipe = pipeline("automatic-speech-recognition", model=model_id)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
title = "Automatic Speech Recognition (ASR)"
|
| 10 |
+
description = """
|
| 11 |
+
Demo for automatic speech recognition in German. Demo uses [Sandiago21/whisper-large-v2-german](https://huggingface.co/Sandiago21/whisper-large-v2-german) checkpoint, which is based on OpenAI's
|
| 12 |
+
[Whisper](https://huggingface.co/openai/whisper-large-v2) model and is fine-tuned in German Audio dataset
|
| 13 |
+
")
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
def transcribe_speech(filepath):
|
| 17 |
+
output = pipe(
|
| 18 |
+
filepath,
|
| 19 |
+
max_new_tokens=256,
|
| 20 |
+
generate_kwargs={
|
| 21 |
+
"task": "transcribe",
|
| 22 |
+
"language": "german",
|
| 23 |
+
}, # update with the language you've fine-tuned on
|
| 24 |
+
chunk_length_s=30,
|
| 25 |
+
batch_size=8,
|
| 26 |
+
)
|
| 27 |
+
return output["text"]
|
| 28 |
+
|
| 29 |
+
demo = gr.Blocks()
|
| 30 |
+
|
| 31 |
+
mic_transcribe = gr.Interface(
|
| 32 |
+
fn=transcribe_speech,
|
| 33 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
| 34 |
+
outputs=gr.outputs.Textbox(),
|
| 35 |
+
tilte=title,
|
| 36 |
+
description=description,
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
file_transcribe = gr.Interface(
|
| 40 |
+
fn=transcribe_speech,
|
| 41 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
| 42 |
+
outputs=gr.outputs.Textbox(),
|
| 43 |
+
examples=[["./example.wav"]],
|
| 44 |
+
tilte=title,
|
| 45 |
+
description=description,
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
with demo:
|
| 49 |
+
gr.TabbedInterface(
|
| 50 |
+
[mic_transcribe, file_transcribe],
|
| 51 |
+
["Transcribe Microphone", "Transcribe Audio File"],
|
| 52 |
+
),
|
| 53 |
+
|
| 54 |
+
demo.launch()
|
example.wav
ADDED
|
Binary file (453 kB). View file
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|