smjain commited on
Commit
6378aa9
1 Parent(s): 4287b9c

Upload infertest.py

Browse files
Files changed (1) hide show
  1. 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
- command = [
484
- 'ffmpeg', '-y',
485
- '-i', inst_path,
486
- '-i', vocal_path,
487
- '-filter_complex', 'amix=inputs=2:duration=longest',
488
- '-b:a', '320k',
489
- '-c:a', 'libmp3lame',
490
- output_path
 
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)