|
import gradio as gr |
|
from transformers import pipeline |
|
import os |
|
|
|
|
|
pipe = pipeline(task="automatic-speech-recognition", model="geokanaan/Whisper_Base_Lebanese_Arabizi") |
|
def transcribe(audio): |
|
sr, y = audio |
|
y = y.astype(np.float32) |
|
y /= np.max(np.abs(y)) |
|
|
|
return pipe({"sampling_rate": sr, "raw": y})["text"] |
|
|
|
HF_TOKEN = os.getenv('WRITE') |
|
|
|
|
|
iface = gr.Interface( |
|
fn=transcribe, |
|
inputs=[ |
|
gr.Audio(sources="microphone") |
|
], |
|
outputs="text", |
|
title="arabeasy", |
|
description="Realtime demo for Lebanese Arabizi speech recognition", |
|
|
|
|
|
) |
|
iface.launch() |