german-asr / app.py
flozi00's picture
Update app.py
2e8cc61
raw
history blame
859 Bytes
from transformers import pipeline
import gradio as gr
import re
p = pipeline("automatic-speech-recognition", model="aware-ai/robust-wav2vec2-base-german")
ttp = pipeline("text2text-generation", model="aware-ai/marian-german-grammar")
def transcribe(audio):
transcribed = p(audio, chunk_length_s=10, stride_length_s=(4, 2))["text"].lower()
transcribed_corrected = ttp(re.sub("[^a-zA-Z0-9öäüÖÄÜ ]", " ",transcribed))[0]["generated_text"]
return transcribed_corrected
def get_asr_interface():
return gr.Interface(
fn=transcribe,
inputs=[
gr.inputs.Audio(source="microphone", type="filepath")
],
outputs=[
"textbox"
])
interfaces = [
get_asr_interface(),
]
names = [
"ASR",
]
gradio.TabbedInterface(interfaces, names).launch(server_name = "0.0.0.0")