clementruhm commited on
Commit
9c7fd5c
·
1 Parent(s): 94e4bbe

Handle stereo files in case those are provided

Browse files
Files changed (1) hide show
  1. vc_service_request.py +4 -0
vc_service_request.py CHANGED
@@ -33,6 +33,10 @@ def prepare_audio(audio: Tuple[int, np.ndarray]) -> np.ndarray:
33
  mult = 32767.0 if np.max(np.abs(wav)) <= 1.0 else 1.0
34
  wav = (wav * mult).astype(np.int16)
35
 
 
 
 
 
36
  # ensure proper sampling rate
37
  if sr != 16000:
38
  wav = (wav / 32768.0).astype(np.float)
 
33
  mult = 32767.0 if np.max(np.abs(wav)) <= 1.0 else 1.0
34
  wav = (wav * mult).astype(np.int16)
35
 
36
+ if wav.ndim == 2:
37
+ # average channels
38
+ wav = np.mean(wav, axis=0, keepdims=False)
39
+
40
  # ensure proper sampling rate
41
  if sr != 16000:
42
  wav = (wav / 32768.0).astype(np.float)