Spaces:
Runtime error
Runtime error
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") |