Spaces:
Running
on
Zero
Running
on
Zero
fix!: resolve problem of m4a
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import logging
|
|
10 |
from inference import proc_folder_direct
|
11 |
from pathlib import Path
|
12 |
import spaces
|
|
|
13 |
|
14 |
OUTPUT_FOLDER = "separation_results/"
|
15 |
INPUT_FOLDER = "input"
|
@@ -119,10 +120,18 @@ def combine_stems_for_all(input_dir, output_format):
|
|
119 |
# Trim silence from the end of the combined audio
|
120 |
trimmed_combined = trim_silence_at_end(combined)
|
121 |
|
122 |
-
# Determine the output file format
|
123 |
output_file = os.path.join(subdir, f"{song_name}.{output_format}")
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
return output_file
|
128 |
|
|
|
10 |
from inference import proc_folder_direct
|
11 |
from pathlib import Path
|
12 |
import spaces
|
13 |
+
from pydub.exceptions import CouldntEncodeError
|
14 |
|
15 |
OUTPUT_FOLDER = "separation_results/"
|
16 |
INPUT_FOLDER = "input"
|
|
|
120 |
# Trim silence from the end of the combined audio
|
121 |
trimmed_combined = trim_silence_at_end(combined)
|
122 |
|
123 |
+
# Determine the output file format and codec
|
124 |
output_file = os.path.join(subdir, f"{song_name}.{output_format}")
|
125 |
+
|
126 |
+
try:
|
127 |
+
if output_format == "m4a":
|
128 |
+
trimmed_combined.export(output_file, format="ipod", codec="aac")
|
129 |
+
else:
|
130 |
+
trimmed_combined.export(output_file, format=output_format)
|
131 |
+
print(f"Exported combined stems to {output_file}")
|
132 |
+
except CouldntEncodeError as e:
|
133 |
+
print(f"Encoding failed: {e}")
|
134 |
+
raise
|
135 |
|
136 |
return output_file
|
137 |
|