Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -48,20 +48,17 @@ def generate_segment_audio(text, lang, speaker_url, pipe):
|
|
48 |
return audio_np
|
49 |
|
50 |
def concatenate_audio_segments(segments):
|
51 |
-
|
52 |
-
for
|
53 |
-
if
|
54 |
-
|
|
|
|
|
55 |
else:
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
concatenated_audio = np.
|
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
|
65 |
concatenated_audio = concatenated_audio / np.max(np.abs(concatenated_audio))
|
66 |
return concatenated_audio
|
67 |
|
|
|
48 |
return audio_np
|
49 |
|
50 |
def concatenate_audio_segments(segments):
|
51 |
+
concatenated_audio_data = []
|
52 |
+
for segment in segments:
|
53 |
+
if segment.ndim == 1:
|
54 |
+
stereo_segment = np.stack((segment, segment), axis=-1)
|
55 |
+
elif segment.shape[1] == 1:
|
56 |
+
stereo_segment = np.concatenate((segment, segment), axis=1)
|
57 |
else:
|
58 |
+
stereo_segment = segment
|
59 |
+
|
60 |
+
concatenated_audio_data.append(stereo_segment)
|
61 |
+
concatenated_audio = np.vstack(concatenated_audio_data)
|
|
|
|
|
|
|
|
|
|
|
62 |
concatenated_audio = concatenated_audio / np.max(np.abs(concatenated_audio))
|
63 |
return concatenated_audio
|
64 |
|