Tonic commited on
Commit
e4243e0
·
verified ·
1 Parent(s): 084c0d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -47,12 +47,18 @@ def generate_segment_audio(text, lang, speaker_url, pipe):
47
  audio_np = audio_data_resampled.cpu().numpy()
48
  return audio_np
49
 
50
- # Function to concatenate audio segments in stereo
51
  def concatenate_audio_segments(segments):
52
- total_length = sum(seg.shape[0] for seg in segments)
 
 
 
 
 
 
 
53
  concatenated_audio = np.zeros((total_length, 2), dtype=np.float32)
54
  current_index = 0
55
- for seg in segments:
56
  end_index = current_index + seg.shape[0]
57
  concatenated_audio[current_index:end_index, :] = seg
58
  current_index = end_index
 
47
  audio_np = audio_data_resampled.cpu().numpy()
48
  return audio_np
49
 
 
50
  def concatenate_audio_segments(segments):
51
+ stereo_segments = []
52
+ for seg in segments:
53
+ if seg.ndim == 1 or seg.shape[1] == 1:
54
+ stereo_seg = np.stack((seg, seg), axis=-1)
55
+ else:
56
+ stereo_seg = seg
57
+ stereo_segments.append(stereo_seg)
58
+ total_length = sum(seg.shape[0] for seg in stereo_segments)
59
  concatenated_audio = np.zeros((total_length, 2), dtype=np.float32)
60
  current_index = 0
61
+ for seg in stereo_segments:
62
  end_index = current_index + seg.shape[0]
63
  concatenated_audio[current_index:end_index, :] = seg
64
  current_index = end_index