Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -46,9 +46,10 @@ def generate_segment_audio(text, lang, speaker_url, pipe):
|
|
46 |
audio_np = audio_data_resampled.cpu().numpy()
|
47 |
return audio_np
|
48 |
|
49 |
-
# Function to concatenate audio segments
|
50 |
def concatenate_audio_segments(segments):
|
51 |
-
|
|
|
|
|
52 |
concatenated_audio = concatenated_audio / np.max(np.abs(concatenated_audio))
|
53 |
return np.asarray(concatenated_audio, dtype=np.float32)
|
54 |
|
|
|
46 |
audio_np = audio_data_resampled.cpu().numpy()
|
47 |
return audio_np
|
48 |
|
|
|
49 |
def concatenate_audio_segments(segments):
|
50 |
+
max_len = max([seg.shape[0] for seg in segments])
|
51 |
+
padded_segments = [np.pad(seg, (0, max_len - seg.shape[0]), 'constant') for seg in segments]
|
52 |
+
concatenated_audio = np.concatenate(padded_segments, axis=0)
|
53 |
concatenated_audio = concatenated_audio / np.max(np.abs(concatenated_audio))
|
54 |
return np.asarray(concatenated_audio, dtype=np.float32)
|
55 |
|