Update barks.py
Browse files
barks.py
CHANGED
@@ -303,9 +303,11 @@ def generate_vocals(vocal_prompt: str, total_duration: int):
|
|
303 |
|
304 |
# Convert to numpy and create AudioSegment
|
305 |
vocal_array = vocal_array.cpu().numpy().squeeze()
|
306 |
-
sample_rate =
|
307 |
temp_vocal_path = "temp_vocal.wav"
|
308 |
-
torchaudio.save
|
|
|
|
|
309 |
vocal_segment = AudioSegment.from_wav(temp_vocal_path)
|
310 |
os.remove(temp_vocal_path)
|
311 |
|
|
|
303 |
|
304 |
# Convert to numpy and create AudioSegment
|
305 |
vocal_array = vocal_array.cpu().numpy().squeeze()
|
306 |
+
sample_rate = 24000 # Default sample rate for suno/bark-small
|
307 |
temp_vocal_path = "temp_vocal.wav"
|
308 |
+
# Convert tensor to float32 for torchaudio.save compatibility
|
309 |
+
vocal_tensor = torch.tensor(vocal_array, dtype=torch.float32).unsqueeze(0)
|
310 |
+
torchaudio.save(temp_vocal_path, vocal_tensor, sample_rate)
|
311 |
vocal_segment = AudioSegment.from_wav(temp_vocal_path)
|
312 |
os.remove(temp_vocal_path)
|
313 |
|