Spaces:
Runtime error
Runtime error
pengdaqian
commited on
Commit
·
2f8d98c
1
Parent(s):
5fefea8
fix
Browse files
app.py
CHANGED
@@ -212,20 +212,26 @@ def svc_main(sid, input_audio):
|
|
212 |
vocals = librosa.resample(vocals, orig_sr=sampling_rate, target_sr=16000)
|
213 |
if len(vocals) > 16000 * 100:
|
214 |
vocals = vocals[:16000 * 100]
|
215 |
-
|
|
|
216 |
soundfile.write(wav_path, vocals, 16000, format="wav")
|
217 |
|
218 |
out_vocals = svc_change(wav_path, f"configs/singers/singer00{sid}.npy")
|
219 |
out_vocals_filepath = os.path.join(curr_tmp_path, 'out_vocals.wav')
|
220 |
soundfile.write(out_vocals_filepath, out_vocals, 48000, format="wav")
|
|
|
221 |
|
|
|
222 |
sound1 = AudioSegment.from_file(out_vocals_filepath)
|
223 |
sound2 = AudioSegment.from_file(accompaniment_filepath)
|
224 |
|
225 |
played_togther = sound1.overlay(sound2)
|
|
|
226 |
|
227 |
result_path = os.path.join(curr_tmp_path, 'out_song.wav')
|
228 |
played_togther.export(result_path, format="wav")
|
|
|
|
|
229 |
result, sampling_rate = soundfile.read(result_path, dtype=np.int16)
|
230 |
|
231 |
return "Success", (sampling_rate, result)
|
@@ -338,7 +344,8 @@ with app:
|
|
338 |
|
339 |
app.queue(
|
340 |
concurrency_count=2,
|
341 |
-
max_size=30
|
|
|
342 |
).launch(
|
343 |
debug=True,
|
344 |
max_threads=150
|
|
|
212 |
vocals = librosa.resample(vocals, orig_sr=sampling_rate, target_sr=16000)
|
213 |
if len(vocals) > 16000 * 100:
|
214 |
vocals = vocals[:16000 * 100]
|
215 |
+
|
216 |
+
wav_path = os.path.join(curr_tmp_path, "temp.wav")
|
217 |
soundfile.write(wav_path, vocals, 16000, format="wav")
|
218 |
|
219 |
out_vocals = svc_change(wav_path, f"configs/singers/singer00{sid}.npy")
|
220 |
out_vocals_filepath = os.path.join(curr_tmp_path, 'out_vocals.wav')
|
221 |
soundfile.write(out_vocals_filepath, out_vocals, 48000, format="wav")
|
222 |
+
print(f"out_vocals_filepath: {out_vocals_filepath}")
|
223 |
|
224 |
+
print("start to mix")
|
225 |
sound1 = AudioSegment.from_file(out_vocals_filepath)
|
226 |
sound2 = AudioSegment.from_file(accompaniment_filepath)
|
227 |
|
228 |
played_togther = sound1.overlay(sound2)
|
229 |
+
print("mix done")
|
230 |
|
231 |
result_path = os.path.join(curr_tmp_path, 'out_song.wav')
|
232 |
played_togther.export(result_path, format="wav")
|
233 |
+
print(f"result_path: {result_path}")
|
234 |
+
|
235 |
result, sampling_rate = soundfile.read(result_path, dtype=np.int16)
|
236 |
|
237 |
return "Success", (sampling_rate, result)
|
|
|
344 |
|
345 |
app.queue(
|
346 |
concurrency_count=2,
|
347 |
+
max_size=30,
|
348 |
+
api_open=False
|
349 |
).launch(
|
350 |
debug=True,
|
351 |
max_threads=150
|