vpavlenko commited on
Commit
d09f276
·
1 Parent(s): 00b2148

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -50,14 +50,25 @@ HEADER = """
50
  CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
51
 
52
  def compress_files(folder_path, dissector_file, original_audio):
53
- """Compresses files in the specified folder into a .zip file"""
 
 
 
 
 
 
 
 
 
 
 
54
  zip_path = folder_path + ".zip"
55
  with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
56
- for root, _, files in os.walk(folder_path):
57
- for file in files:
58
- zipf.write(os.path.join(root, file), arcname=file)
59
- zipf.write(dissector_file, arcname='dissector.json') # Fixed the name
60
  zipf.write(original_audio, arcname='mixdown.mp3') # Added original audio
 
61
  return zip_path
62
 
63
  def analyze(path):
 
50
  CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
51
 
52
  def compress_files(folder_path, dissector_file, original_audio):
53
+ """Compresses specific files in the specified folder into a .zip file"""
54
+ # List of the files to be compressed
55
+ wav_files = ['bass.wav', 'drums.wav', 'other.wav', 'vocals.wav']
56
+ mp3_files = [file.replace('.wav', '.mp3') for file in wav_files]
57
+
58
+ # Convert each .wav file to .mp3 using ffmpeg
59
+ for wav, mp3 in zip(wav_files, mp3_files):
60
+ command = ["ffmpeg", "-i", os.path.join(folder_path, wav), os.path.join(folder_path, mp3)]
61
+ process = Popen(command)
62
+ process.communicate()
63
+
64
+ # Compress the files
65
  zip_path = folder_path + ".zip"
66
  with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
67
+ for mp3 in mp3_files:
68
+ zipf.write(os.path.join(folder_path, mp3), arcname=mp3)
69
+ zipf.write(dissector_file, arcname='dissector.json') # Fixed name
 
70
  zipf.write(original_audio, arcname='mixdown.mp3') # Added original audio
71
+
72
  return zip_path
73
 
74
  def analyze(path):