live_Arabic_ASR / app.py
papasega's picture
Create app.py
daee104 verified
raw
history blame
833 Bytes
import gradio as gr
from transformers import pipeline
import numpy as np
transcriber = pipeline("automatic-speech-recognition", model="jonatasgrosman/wav2vec2-large-xlsr-53-arabic")
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="S2T: Transcription automatique en live de l'arabe en text by Papa Séga",
description="Utilisez le microphone pour parler en arabe et la transcription démarre en quelques secondes"
)
demo.launch()