german-asr / app.py
flozi00's picture
Update app.py
eac9cba
raw
history blame
657 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 = ttp(re.sub("[^a-zA-Z0-9öäüÖÄÜ ]", " ",transcribed))[0]["generated_text"]
return transcribed
gr.Interface(
fn=transcribe,
inputs=[
gr.inputs.Audio(source="microphone", type="filepath")
],
outputs=[
"textbox"
]).launch(server_name = "0.0.0.0")