WebashalarForML commited on
Commit
e9f94b1
·
verified ·
1 Parent(s): 0e1dba2

Update audio.py

Browse files
Files changed (1) hide show
  1. audio.py +4 -6
audio.py CHANGED
@@ -6,15 +6,13 @@ import resampy
6
  from hparams import hparams as hp
7
 
8
  def load_wav(path, sr):
9
- """
10
- Load a WAV file and resample it using scipy + resampy.
11
- """
12
  orig_sr, audio = wavfile.read(path)
13
 
14
- # Normalize if needed
 
 
15
  if audio.dtype.kind == 'i':
16
- max_val = np.iinfo(audio.dtype).max
17
- audio = audio.astype(np.float32) / max_val
18
  else:
19
  audio = audio.astype(np.float32)
20
 
 
6
  from hparams import hparams as hp
7
 
8
  def load_wav(path, sr):
 
 
 
9
  orig_sr, audio = wavfile.read(path)
10
 
11
+ if len(audio) < 100: # Arbitrary threshold (can be higher for safety)
12
+ raise ValueError(f"Input audio too short: {len(audio)} samples")
13
+
14
  if audio.dtype.kind == 'i':
15
+ audio = audio.astype(np.float32) / np.iinfo(audio.dtype).max
 
16
  else:
17
  audio = audio.astype(np.float32)
18