File size: 803 Bytes
9477b96 ca8582b 9477b96 ca8582b 8ef0b5c ca8582b 8ef0b5c 9477b96 | 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 | # handler.py
class EndpointHandler:
def __init__(self, path=""):
# lazy import only inside init
from omnilingual_asr.models.inference.pipeline import ASRInferencePipeline
# Load the omniASR pipeline
self.pipeline = ASRInferencePipeline(model_card="facebook/omniASR-LLM-7B")
def __call__(self, data):
# import here so it doesn’t trigger during module load
import io
import soundfile as sf
# read raw bytes
audio_bytes = data.get("inputs")
if not audio_bytes:
return {"error": "no audio provided"}
f = io.BytesIO(audio_bytes)
audio, sr = sf.read(f)
# run transcription
result = self.pipeline.transcribe([audio], batch_size=1)
return {"text": result} |