import logging import warnings import gradio as gr from transformers import pipeline from transformers.utils.logging import disable_progress_bar warnings.filterwarnings("ignore") disable_progress_bar() 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="bofenghuang/asr-wav2vec2-ctc-french") logger.info("ASR pipeline has been initialized") 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="upload", type="filepath", label="Upload some audio file..."), 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=True) iface.launch()