CoolFace
Apppublic

OSOCONSULT/GRITVOICE45

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
utils.py34 linesDownload Raw Back to root
1import os2import openai3import whisper4from dotenv import load_dotenv5 6load_dotenv()7 8# Whisper model load (lazy loaded)9_model = None10 11def get_model():12    global _model13    if _model is None:14        _model = whisper.load_model("base")15    return _model16 17def transcribe_audio(audio_path):18    model = get_model()19    result = model.transcribe(audio_path)20    return result['text']21 22def route_audio(transcribed_text):23    text = transcribed_text.lower()24    if any(x in text for x in ['help', 'problem', 'advice']):25        return "advisor"26    elif any(x in text for x in ['let’s go', 'you got this', 'push']):27        return "hype"28    elif any(x in text for x in ['hi', 'gentle', 'soft']):29        return "soft"30    elif any(x in text for x in ['joke', 'fun', 'play']):31        return "playful"32    else:33        return "default"34