File size: 855 Bytes
412c852
 
aa756f5
412c852
eac9cba
aa756f5
412c852
191d30d
aa756f5
18e36a8
aa756f5
dad77b7
412c852
2e8cc61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fb40cda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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",
]

gr.TabbedInterface(interfaces, names).launch(server_name = "0.0.0.0")