File size: 888 Bytes
eb937e4
 
f0b2cfd
eb937e4
 
 
07fa407
eb937e4
 
 
 
f0b2cfd
 
 
 
 
 
 
eb937e4
f0b2cfd
 
 
 
 
 
 
 
 
 
 
 
eb937e4
f0b2cfd
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
33
34
import logging

import gradio as gr
from transformers import pipeline

logging.basicConfig(
    format="%(asctime)s [%(levelname)s] [%(name)s] %(message)s",
    datefmt="%Y-%m-%dT%H:%M:%SZ",
)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

pipe = pipeline(model="bhuang/wav2vec2-xls-r-1b-cv9-fr")


def transcribe(audio):
    # text = pipe(audio, chunk_length_s=30, stride_length_s=5)["text"]
    text = pipe(audio)["text"]
    logger.info(f"Transcription for {audio}: {text}")
    return text


iface = gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(source="microphone", type="filepath", label="Record something..."),
    outputs="text",
    title="Speech-to-Text in French",
    description="Realtime demo for French automatic speech recognition.",
    allow_flagging="never",
)

# iface.launch(server_name="0.0.0.0", debug=True, share=False)
iface.launch()