CoolFace
Apppublic

comodoro/Wav2Vec2-XLS-R-CS

sourceHugging Facecc-by-nc-sa-4.0updated 4y agoView on Hugging Face
0likes
app.py30 linesDownload Raw Back to root
1from transformers import pipeline, AutoFeatureExtractor, AutoTokenizer, Wav2Vec2ForCTC2import gradio as gr3import time4 5model_id = 'comodoro/wav2vec2-xls-r-300m-cs-250'6feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)7model = Wav2Vec2ForCTC.from_pretrained(model_id)8tokenizer = AutoTokenizer.from_pretrained(model_id)9 10p = pipeline("automatic-speech-recognition", chunk_length_s=5, model=model, 11    tokenizer=tokenizer, feature_extractor=feature_extractor)12 13def transcribe(audio, state=""):14    time.sleep(2)15    text = p(audio)["text"]16    state += text + " "17    return state, state18 19gr.Interface(20    fn=transcribe, 21    inputs=[22        gr.inputs.Audio(source="microphone", type="filepath"), 23        "state"24    ],25    outputs=[26        "textbox",27        "state"28    ],29    live=True).launch(debug=True)30