plutoa386 commited on
Commit
2546efa
·
1 Parent(s): 98bb18b

fixed missing whisper and spacy modules and respective loader functions.

Browse files
Files changed (1) hide show
  1. dataloaderImp.py +22 -0
dataloaderImp.py CHANGED
@@ -1,6 +1,8 @@
1
  import os
2
  import json
3
  import tempfile
 
 
4
  import pandas as pd
5
  import librosa
6
  import numpy as np
@@ -22,6 +24,26 @@ if not firebase_admin._apps:
22
  db = firestore.client()
23
  bucket = storage.bucket()
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  def extract_audio_features(wav_path):
26
  """Extract MFCC, ZCR, RMS from a single .wav file"""
27
  try:
 
1
  import os
2
  import json
3
  import tempfile
4
+ import spacy
5
+ import whisper
6
  import pandas as pd
7
  import librosa
8
  import numpy as np
 
24
  db = firestore.client()
25
  bucket = storage.bucket()
26
 
27
+ # Lazy-loaded model placeholders
28
+ _whisper_model = None
29
+ _nlp = None
30
+
31
+ def _load_whisper():
32
+ global _whisper_model
33
+ if _whisper_model is None:
34
+ import whisper
35
+ print("Loading Whisper model...")
36
+ _whisper_model = whisper.load_model("medium")
37
+ return _whisper_model
38
+
39
+ def _load_spacy():
40
+ global _nlp
41
+ if _nlp is None:
42
+ import spacy
43
+ print("Loading spaCy model...")
44
+ _nlp = spacy.load("en_core_web_sm")
45
+ return _nlp
46
+
47
  def extract_audio_features(wav_path):
48
  """Extract MFCC, ZCR, RMS from a single .wav file"""
49
  try: