ayush2917 commited on
Commit
7915eb3
·
verified ·
1 Parent(s): 3c156fb

Create asr.py

Browse files
Files changed (1) hide show
  1. models/asr.py +14 -0
models/asr.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # models/asr.py
2
+
3
+ import whisper
4
+ from config.hf_config import ASR_MODEL_NAME
5
+
6
+ # Load Whisper model once
7
+ asr_model = whisper.load_model(ASR_MODEL_NAME.replace("openai/", ""))
8
+
9
+ def transcribe_audio(audio_path: str) -> str:
10
+ """
11
+ Transcribe audio file to text using Whisper.
12
+ """
13
+ result = asr_model.transcribe(audio_path)
14
+ return result["text"]