Spaces:
Sleeping
Sleeping
Upload infertest.py
Browse files- infertest.py +21 -8
infertest.py
CHANGED
@@ -19,6 +19,18 @@ import base64
|
|
19 |
import tempfile
|
20 |
import os
|
21 |
import werkzeug
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
app = Flask(__name__)
|
23 |
|
24 |
now_dir = os.getcwd()
|
@@ -480,14 +492,15 @@ def combine_vocal_and_inst(vocal_path, inst_path):
|
|
480 |
output_path = "output/result/combine.mp3"
|
481 |
#command = f'ffmpeg -y -i "{inst_path}" -i "{vocal_path}" -filter_complex [0:a]volume={inst_volume}[i];[1:a]volume={vocal_volume}[v];[i][v]amix=inputs=2:duration=longest[a] -map [a] -b:a 320k -c:a libmp3lame "{output_path}"'
|
482 |
#command=f'ffmpeg -y -i "{inst_path}" -i "{vocal_path}" -filter_complex "amix=inputs=2:duration=longest" -b:a 320k -c:a libmp3lame "{output_path}"'
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
|
|
491 |
]
|
492 |
#result = subprocess.run(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
493 |
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
19 |
import tempfile
|
20 |
import os
|
21 |
import werkzeug
|
22 |
+
from pydub import AudioSegment
|
23 |
+
|
24 |
+
# Load the audio files
|
25 |
+
vocal = AudioSegment.from_file("vocal_path.wav")
|
26 |
+
instrumental = AudioSegment.from_file("inst_path.wav")
|
27 |
+
|
28 |
+
# Overlay the vocal track on top of the instrumental track
|
29 |
+
combined = vocal.overlay(instrumental)
|
30 |
+
|
31 |
+
# Export the result
|
32 |
+
combined.export("output/result/combine.mp3", format="mp3")
|
33 |
+
|
34 |
app = Flask(__name__)
|
35 |
|
36 |
now_dir = os.getcwd()
|
|
|
492 |
output_path = "output/result/combine.mp3"
|
493 |
#command = f'ffmpeg -y -i "{inst_path}" -i "{vocal_path}" -filter_complex [0:a]volume={inst_volume}[i];[1:a]volume={vocal_volume}[v];[i][v]amix=inputs=2:duration=longest[a] -map [a] -b:a 320k -c:a libmp3lame "{output_path}"'
|
494 |
#command=f'ffmpeg -y -i "{inst_path}" -i "{vocal_path}" -filter_complex "amix=inputs=2:duration=longest" -b:a 320k -c:a libmp3lame "{output_path}"'
|
495 |
+
# Load the audio files
|
496 |
+
vocal = AudioSegment.from_file(vocal_path.wav)
|
497 |
+
instrumental = AudioSegment.from_file(inst_path.wav)
|
498 |
+
|
499 |
+
# Overlay the vocal track on top of the instrumental track
|
500 |
+
combined = vocal.overlay(instrumental)
|
501 |
+
|
502 |
+
# Export the result
|
503 |
+
combined.export("output/result/combine.mp3", format="mp3")
|
504 |
]
|
505 |
#result = subprocess.run(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
506 |
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|