import gradio as gr from transformers import pipeline import os transcriber = pipeline(task="automatic-speech-recognition", model="geokanaan/Whisper_Base_Lebanese_Arabizi") HF_TOKEN = os.getenv('WRITE') hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "flagged_Audio_Lebanese") def transcribe(stream, new_chunk): sr, y = new_chunk y = y.astype(np.float32) y /= np.max(np.abs(y)) if stream is not None: stream = np.concatenate([stream, y]) else: stream = y return stream, transcriber({"sampling_rate": sr, "raw": stream})["text"] demo = gr.Interface( transcribe, ["state", gr.Audio(sources=["microphone"], streaming=True)], ["state", "text"], live=True, title="UNDER MAINTENANCE", description="Realtime demo for Lebanese Arabizi speech recognition", allow_flagging='manual', # Enable manual flagging ) demo.launch()