karaoke-gen 0.59.0__py3-none-any.whl → 0.61.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of karaoke-gen might be problematic. Click here for more details.
- karaoke_gen/audio_processor.py +346 -28
- karaoke_gen/karaoke_gen.py +9 -9
- {karaoke_gen-0.59.0.dist-info → karaoke_gen-0.61.0.dist-info}/METADATA +42 -1
- {karaoke_gen-0.59.0.dist-info → karaoke_gen-0.61.0.dist-info}/RECORD +7 -7
- {karaoke_gen-0.59.0.dist-info → karaoke_gen-0.61.0.dist-info}/LICENSE +0 -0
- {karaoke_gen-0.59.0.dist-info → karaoke_gen-0.61.0.dist-info}/WHEEL +0 -0
- {karaoke_gen-0.59.0.dist-info → karaoke_gen-0.61.0.dist-info}/entry_points.txt +0 -0
karaoke_gen/audio_processor.py
CHANGED
|
@@ -12,6 +12,14 @@ import psutil
|
|
|
12
12
|
from datetime import datetime
|
|
13
13
|
from pydub import AudioSegment
|
|
14
14
|
|
|
15
|
+
# Try to import the remote API client if available
|
|
16
|
+
try:
|
|
17
|
+
from audio_separator.remote import AudioSeparatorAPIClient
|
|
18
|
+
REMOTE_API_AVAILABLE = True
|
|
19
|
+
except ImportError:
|
|
20
|
+
REMOTE_API_AVAILABLE = False
|
|
21
|
+
AudioSeparatorAPIClient = None
|
|
22
|
+
|
|
15
23
|
|
|
16
24
|
# Placeholder class or functions for audio processing
|
|
17
25
|
class AudioProcessor:
|
|
@@ -104,9 +112,36 @@ class AudioProcessor:
|
|
|
104
112
|
self.logger.info(f"Separation complete! Output file(s): {vocals_path} {instrumental_path}")
|
|
105
113
|
|
|
106
114
|
def process_audio_separation(self, audio_file, artist_title, track_output_dir):
|
|
115
|
+
# Check if we should use remote API
|
|
116
|
+
remote_api_url = os.environ.get("AUDIO_SEPARATOR_API_URL")
|
|
117
|
+
if remote_api_url:
|
|
118
|
+
if not REMOTE_API_AVAILABLE:
|
|
119
|
+
self.logger.warning("AUDIO_SEPARATOR_API_URL is set but remote API client is not available. "
|
|
120
|
+
"Please ensure audio-separator is updated to a version that includes remote API support. "
|
|
121
|
+
"Falling back to local processing.")
|
|
122
|
+
else:
|
|
123
|
+
self.logger.info(f"Using remote audio separator API at: {remote_api_url}")
|
|
124
|
+
try:
|
|
125
|
+
return self._process_audio_separation_remote(audio_file, artist_title, track_output_dir, remote_api_url)
|
|
126
|
+
except Exception as e:
|
|
127
|
+
error_str = str(e)
|
|
128
|
+
# Don't fall back for download failures - these indicate API issues that should be fixed
|
|
129
|
+
if ("no files were downloaded" in error_str or
|
|
130
|
+
"failed to produce essential" in error_str):
|
|
131
|
+
self.logger.error(f"Remote API processing failed with download/file organization issue: {error_str}")
|
|
132
|
+
self.logger.error("This indicates an audio-separator API issue that should be fixed. Not falling back to local processing.")
|
|
133
|
+
raise e
|
|
134
|
+
else:
|
|
135
|
+
# Fall back for other types of errors (network issues, etc.)
|
|
136
|
+
self.logger.error(f"Remote API processing failed: {error_str}")
|
|
137
|
+
self.logger.info("Falling back to local audio separation")
|
|
138
|
+
else:
|
|
139
|
+
self.logger.info("AUDIO_SEPARATOR_API_URL not set, using local audio separation. "
|
|
140
|
+
"Set this environment variable to use remote GPU processing.")
|
|
141
|
+
|
|
107
142
|
from audio_separator.separator import Separator
|
|
108
143
|
|
|
109
|
-
self.logger.info(f"Starting audio separation process for {artist_title}")
|
|
144
|
+
self.logger.info(f"Starting local audio separation process for {artist_title}")
|
|
110
145
|
|
|
111
146
|
# Define lock file path in system temp directory
|
|
112
147
|
lock_file_path = os.path.join(tempfile.gettempdir(), "audio_separator.lock")
|
|
@@ -203,33 +238,34 @@ class AudioProcessor:
|
|
|
203
238
|
self._normalize_audio_files(result, artist_title, track_output_dir)
|
|
204
239
|
|
|
205
240
|
# Create Audacity LOF file
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
241
|
+
if result["backing_vocals"]:
|
|
242
|
+
lof_path = os.path.join(stems_dir, f"{artist_title} (Audacity).lof")
|
|
243
|
+
first_model = list(result["backing_vocals"].keys())[0]
|
|
244
|
+
|
|
245
|
+
files_to_include = [
|
|
246
|
+
audio_file, # Original audio
|
|
247
|
+
result["clean_instrumental"]["instrumental"], # Clean instrumental
|
|
248
|
+
result["backing_vocals"][first_model]["backing_vocals"], # Backing vocals
|
|
249
|
+
result["combined_instrumentals"][first_model], # Combined instrumental+BV
|
|
250
|
+
]
|
|
251
|
+
|
|
252
|
+
# Convert to absolute paths
|
|
253
|
+
files_to_include = [os.path.abspath(f) for f in files_to_include]
|
|
254
|
+
|
|
255
|
+
with open(lof_path, "w") as lof:
|
|
256
|
+
for file_path in files_to_include:
|
|
257
|
+
lof.write(f'file "{file_path}"\n')
|
|
258
|
+
|
|
259
|
+
self.logger.info(f"Created Audacity LOF file: {lof_path}")
|
|
260
|
+
result["audacity_lof"] = lof_path
|
|
261
|
+
|
|
262
|
+
# Launch Audacity with multiple tracks
|
|
263
|
+
if sys.platform == "darwin": # Check if we're on macOS
|
|
264
|
+
if lof_path and os.path.exists(lof_path):
|
|
265
|
+
self.logger.info(f"Launching Audacity with LOF file: {lof_path}")
|
|
266
|
+
os.system(f'open -a Audacity "{lof_path}"')
|
|
267
|
+
else:
|
|
268
|
+
self.logger.debug("Audacity LOF file not available or not found")
|
|
233
269
|
|
|
234
270
|
self.logger.info("Audio separation, combination, and normalization process completed")
|
|
235
271
|
return result
|
|
@@ -242,6 +278,288 @@ class AudioProcessor:
|
|
|
242
278
|
except OSError:
|
|
243
279
|
pass
|
|
244
280
|
|
|
281
|
+
def _process_audio_separation_remote(self, audio_file, artist_title, track_output_dir, remote_api_url):
|
|
282
|
+
"""Process audio separation using remote API with proper two-stage workflow."""
|
|
283
|
+
self.logger.info(f"Starting remote audio separation process for {artist_title}")
|
|
284
|
+
|
|
285
|
+
# Initialize the API client
|
|
286
|
+
api_client = AudioSeparatorAPIClient(remote_api_url, self.logger)
|
|
287
|
+
|
|
288
|
+
stems_dir = self._create_stems_directory(track_output_dir)
|
|
289
|
+
result = {"clean_instrumental": {}, "other_stems": {}, "backing_vocals": {}, "combined_instrumentals": {}}
|
|
290
|
+
|
|
291
|
+
if os.environ.get("KARAOKE_GEN_SKIP_AUDIO_SEPARATION"):
|
|
292
|
+
return result
|
|
293
|
+
|
|
294
|
+
try:
|
|
295
|
+
# Stage 1: Process original song with clean instrumental model + other stems models
|
|
296
|
+
stage1_models = []
|
|
297
|
+
if self.clean_instrumental_model:
|
|
298
|
+
stage1_models.append(self.clean_instrumental_model)
|
|
299
|
+
stage1_models.extend(self.other_stems_models)
|
|
300
|
+
|
|
301
|
+
self.logger.info(f"Stage 1: Submitting audio separation job with models: {stage1_models}")
|
|
302
|
+
|
|
303
|
+
# Submit the first stage job
|
|
304
|
+
stage1_result = api_client.separate_audio_and_wait(
|
|
305
|
+
audio_file,
|
|
306
|
+
models=stage1_models,
|
|
307
|
+
timeout=1800, # 30 minutes timeout
|
|
308
|
+
poll_interval=15, # Check every 15 seconds
|
|
309
|
+
download=True,
|
|
310
|
+
output_dir=stems_dir,
|
|
311
|
+
output_format=self.lossless_output_format.lower()
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
if stage1_result["status"] != "completed":
|
|
315
|
+
raise Exception(f"Stage 1 remote audio separation failed: {stage1_result.get('error', 'Unknown error')}")
|
|
316
|
+
|
|
317
|
+
self.logger.info(f"Stage 1 completed. Downloaded {len(stage1_result['downloaded_files'])} files")
|
|
318
|
+
|
|
319
|
+
# Check if we actually got the expected files for Stage 1
|
|
320
|
+
if len(stage1_result["downloaded_files"]) == 0:
|
|
321
|
+
error_msg = ("Stage 1 audio separation completed successfully but no files were downloaded. "
|
|
322
|
+
"This indicates a filename encoding or API issue in the audio-separator remote service. "
|
|
323
|
+
f"Expected files for models {stage1_models} but got 0.")
|
|
324
|
+
self.logger.error(error_msg)
|
|
325
|
+
raise Exception(error_msg)
|
|
326
|
+
|
|
327
|
+
# Organize the stage 1 results
|
|
328
|
+
result = self._organize_stage1_remote_results(
|
|
329
|
+
stage1_result["downloaded_files"], artist_title, track_output_dir, stems_dir
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
# Validate that we got the essential clean instrumental outputs
|
|
333
|
+
if not result["clean_instrumental"].get("vocals") or not result["clean_instrumental"].get("instrumental"):
|
|
334
|
+
missing = []
|
|
335
|
+
if not result["clean_instrumental"].get("vocals"):
|
|
336
|
+
missing.append("clean vocals")
|
|
337
|
+
if not result["clean_instrumental"].get("instrumental"):
|
|
338
|
+
missing.append("clean instrumental")
|
|
339
|
+
error_msg = (f"Stage 1 completed but failed to produce essential clean instrumental outputs: {', '.join(missing)}. "
|
|
340
|
+
"This may indicate a model naming or file organization issue in the remote API.")
|
|
341
|
+
self.logger.error(error_msg)
|
|
342
|
+
raise Exception(error_msg)
|
|
343
|
+
|
|
344
|
+
# Stage 2: Process clean vocals with backing vocals models (if we have both)
|
|
345
|
+
if result["clean_instrumental"].get("vocals") and self.backing_vocals_models:
|
|
346
|
+
self.logger.info(f"Stage 2: Processing clean vocals for backing vocals separation...")
|
|
347
|
+
vocals_path = result["clean_instrumental"]["vocals"]
|
|
348
|
+
|
|
349
|
+
stage2_result = api_client.separate_audio_and_wait(
|
|
350
|
+
vocals_path,
|
|
351
|
+
models=self.backing_vocals_models,
|
|
352
|
+
timeout=900, # 15 minutes timeout for backing vocals
|
|
353
|
+
poll_interval=10,
|
|
354
|
+
download=True,
|
|
355
|
+
output_dir=stems_dir,
|
|
356
|
+
output_format=self.lossless_output_format.lower()
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
if stage2_result["status"] == "completed":
|
|
360
|
+
self.logger.info(f"Stage 2 completed. Downloaded {len(stage2_result['downloaded_files'])} files")
|
|
361
|
+
|
|
362
|
+
# Check if we actually got the expected files
|
|
363
|
+
if len(stage2_result["downloaded_files"]) == 0:
|
|
364
|
+
error_msg = ("Stage 2 backing vocals separation completed successfully but no files were downloaded. "
|
|
365
|
+
"This indicates a filename encoding or API issue in the audio-separator remote service. "
|
|
366
|
+
"Expected 2 files (lead vocals + backing vocals) but got 0.")
|
|
367
|
+
self.logger.error(error_msg)
|
|
368
|
+
raise Exception(error_msg)
|
|
369
|
+
|
|
370
|
+
# Organize the stage 2 results (backing vocals)
|
|
371
|
+
backing_vocals_result = self._organize_stage2_remote_results(
|
|
372
|
+
stage2_result["downloaded_files"], artist_title, stems_dir
|
|
373
|
+
)
|
|
374
|
+
result["backing_vocals"] = backing_vocals_result
|
|
375
|
+
else:
|
|
376
|
+
error_msg = f"Stage 2 backing vocals separation failed: {stage2_result.get('error', 'Unknown error')}"
|
|
377
|
+
self.logger.error(error_msg)
|
|
378
|
+
raise Exception(error_msg)
|
|
379
|
+
else:
|
|
380
|
+
result["backing_vocals"] = {}
|
|
381
|
+
|
|
382
|
+
# Generate combined instrumentals
|
|
383
|
+
if result["clean_instrumental"].get("instrumental") and result["backing_vocals"]:
|
|
384
|
+
result["combined_instrumentals"] = self._generate_combined_instrumentals(
|
|
385
|
+
result["clean_instrumental"]["instrumental"], result["backing_vocals"], artist_title, track_output_dir
|
|
386
|
+
)
|
|
387
|
+
else:
|
|
388
|
+
result["combined_instrumentals"] = {}
|
|
389
|
+
|
|
390
|
+
# Normalize audio files
|
|
391
|
+
self._normalize_audio_files(result, artist_title, track_output_dir)
|
|
392
|
+
|
|
393
|
+
# Create Audacity LOF file
|
|
394
|
+
if result["backing_vocals"]:
|
|
395
|
+
lof_path = os.path.join(stems_dir, f"{artist_title} (Audacity).lof")
|
|
396
|
+
first_model = list(result["backing_vocals"].keys())[0]
|
|
397
|
+
|
|
398
|
+
files_to_include = [
|
|
399
|
+
audio_file, # Original audio
|
|
400
|
+
result["clean_instrumental"]["instrumental"], # Clean instrumental
|
|
401
|
+
result["backing_vocals"][first_model]["backing_vocals"], # Backing vocals
|
|
402
|
+
result["combined_instrumentals"][first_model], # Combined instrumental+BV
|
|
403
|
+
]
|
|
404
|
+
|
|
405
|
+
# Convert to absolute paths
|
|
406
|
+
files_to_include = [os.path.abspath(f) for f in files_to_include]
|
|
407
|
+
|
|
408
|
+
with open(lof_path, "w") as lof:
|
|
409
|
+
for file_path in files_to_include:
|
|
410
|
+
lof.write(f'file "{file_path}"\n')
|
|
411
|
+
|
|
412
|
+
self.logger.info(f"Created Audacity LOF file: {lof_path}")
|
|
413
|
+
result["audacity_lof"] = lof_path
|
|
414
|
+
|
|
415
|
+
# Launch Audacity with multiple tracks
|
|
416
|
+
if sys.platform == "darwin": # Check if we're on macOS
|
|
417
|
+
if lof_path and os.path.exists(lof_path):
|
|
418
|
+
self.logger.info(f"Launching Audacity with LOF file: {lof_path}")
|
|
419
|
+
os.system(f'open -a Audacity "{lof_path}"')
|
|
420
|
+
else:
|
|
421
|
+
self.logger.debug("Audacity LOF file not available or not found")
|
|
422
|
+
|
|
423
|
+
self.logger.info("Remote audio separation, combination, and normalization process completed")
|
|
424
|
+
return result
|
|
425
|
+
|
|
426
|
+
except Exception as e:
|
|
427
|
+
self.logger.error(f"Error during remote audio separation: {str(e)}")
|
|
428
|
+
raise e
|
|
429
|
+
|
|
430
|
+
def _organize_stage1_remote_results(self, downloaded_files, artist_title, track_output_dir, stems_dir):
|
|
431
|
+
"""Organize stage 1 separation results (clean instrumental + other stems)."""
|
|
432
|
+
result = {"clean_instrumental": {}, "other_stems": {}}
|
|
433
|
+
|
|
434
|
+
for file_path in downloaded_files:
|
|
435
|
+
filename = os.path.basename(file_path)
|
|
436
|
+
self.logger.debug(f"Stage 1 - Processing downloaded file: {filename}")
|
|
437
|
+
|
|
438
|
+
# Determine which model and stem type this file represents
|
|
439
|
+
model_name = None
|
|
440
|
+
stem_type = None
|
|
441
|
+
|
|
442
|
+
# Extract model name and stem type from filename
|
|
443
|
+
# Expected format: "audio_(StemType)_modelname.ext"
|
|
444
|
+
if "_(Vocals)_" in filename:
|
|
445
|
+
stem_type = "Vocals"
|
|
446
|
+
model_name = filename.split("_(Vocals)_")[1].split(".")[0]
|
|
447
|
+
elif "_(Instrumental)_" in filename:
|
|
448
|
+
stem_type = "Instrumental"
|
|
449
|
+
model_name = filename.split("_(Instrumental)_")[1].split(".")[0]
|
|
450
|
+
elif "_(Drums)_" in filename:
|
|
451
|
+
stem_type = "Drums"
|
|
452
|
+
model_name = filename.split("_(Drums)_")[1].split(".")[0]
|
|
453
|
+
elif "_(Bass)_" in filename:
|
|
454
|
+
stem_type = "Bass"
|
|
455
|
+
model_name = filename.split("_(Bass)_")[1].split(".")[0]
|
|
456
|
+
elif "_(Other)_" in filename:
|
|
457
|
+
stem_type = "Other"
|
|
458
|
+
model_name = filename.split("_(Other)_")[1].split(".")[0]
|
|
459
|
+
elif "_(Guitar)_" in filename:
|
|
460
|
+
stem_type = "Guitar"
|
|
461
|
+
model_name = filename.split("_(Guitar)_")[1].split(".")[0]
|
|
462
|
+
elif "_(Piano)_" in filename:
|
|
463
|
+
stem_type = "Piano"
|
|
464
|
+
model_name = filename.split("_(Piano)_")[1].split(".")[0]
|
|
465
|
+
else:
|
|
466
|
+
# Try to extract stem type from parentheses
|
|
467
|
+
import re
|
|
468
|
+
match = re.search(r'_\(([^)]+)\)_([^.]+)', filename)
|
|
469
|
+
if match:
|
|
470
|
+
stem_type = match.group(1)
|
|
471
|
+
model_name = match.group(2)
|
|
472
|
+
else:
|
|
473
|
+
self.logger.warning(f"Could not parse stem type and model from filename: {filename}")
|
|
474
|
+
continue
|
|
475
|
+
|
|
476
|
+
# Check if this model name matches the clean instrumental model
|
|
477
|
+
is_clean_instrumental_model = (
|
|
478
|
+
model_name == self.clean_instrumental_model or
|
|
479
|
+
self.clean_instrumental_model.startswith(model_name) or
|
|
480
|
+
model_name.startswith(self.clean_instrumental_model.split('.')[0])
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
if is_clean_instrumental_model:
|
|
484
|
+
if stem_type == "Vocals":
|
|
485
|
+
target_path = os.path.join(stems_dir, f"{artist_title} (Vocals {self.clean_instrumental_model}).{self.lossless_output_format}")
|
|
486
|
+
shutil.move(file_path, target_path)
|
|
487
|
+
result["clean_instrumental"]["vocals"] = target_path
|
|
488
|
+
elif stem_type == "Instrumental":
|
|
489
|
+
target_path = os.path.join(track_output_dir, f"{artist_title} (Instrumental {self.clean_instrumental_model}).{self.lossless_output_format}")
|
|
490
|
+
shutil.move(file_path, target_path)
|
|
491
|
+
result["clean_instrumental"]["instrumental"] = target_path
|
|
492
|
+
|
|
493
|
+
elif any(model_name == os_model or os_model.startswith(model_name) or model_name.startswith(os_model.split('.')[0]) for os_model in self.other_stems_models):
|
|
494
|
+
# Find the matching other stems model
|
|
495
|
+
matching_os_model = None
|
|
496
|
+
for os_model in self.other_stems_models:
|
|
497
|
+
if model_name == os_model or os_model.startswith(model_name) or model_name.startswith(os_model.split('.')[0]):
|
|
498
|
+
matching_os_model = os_model
|
|
499
|
+
break
|
|
500
|
+
|
|
501
|
+
if matching_os_model:
|
|
502
|
+
if matching_os_model not in result["other_stems"]:
|
|
503
|
+
result["other_stems"][matching_os_model] = {}
|
|
504
|
+
|
|
505
|
+
target_path = os.path.join(stems_dir, f"{artist_title} ({stem_type} {matching_os_model}).{self.lossless_output_format}")
|
|
506
|
+
shutil.move(file_path, target_path)
|
|
507
|
+
result["other_stems"][matching_os_model][stem_type] = target_path
|
|
508
|
+
|
|
509
|
+
return result
|
|
510
|
+
|
|
511
|
+
def _organize_stage2_remote_results(self, downloaded_files, artist_title, stems_dir):
|
|
512
|
+
"""Organize stage 2 separation results (backing vocals)."""
|
|
513
|
+
result = {}
|
|
514
|
+
|
|
515
|
+
for file_path in downloaded_files:
|
|
516
|
+
filename = os.path.basename(file_path)
|
|
517
|
+
self.logger.debug(f"Stage 2 - Processing downloaded file: {filename}")
|
|
518
|
+
|
|
519
|
+
# Determine which model and stem type this file represents
|
|
520
|
+
model_name = None
|
|
521
|
+
stem_type = None
|
|
522
|
+
|
|
523
|
+
# Extract model name and stem type from filename
|
|
524
|
+
if "_(Vocals)_" in filename:
|
|
525
|
+
stem_type = "Vocals"
|
|
526
|
+
model_name = filename.split("_(Vocals)_")[1].split(".")[0]
|
|
527
|
+
elif "_(Instrumental)_" in filename:
|
|
528
|
+
stem_type = "Instrumental"
|
|
529
|
+
model_name = filename.split("_(Instrumental)_")[1].split(".")[0]
|
|
530
|
+
else:
|
|
531
|
+
# Try to extract stem type from parentheses
|
|
532
|
+
import re
|
|
533
|
+
match = re.search(r'_\(([^)]+)\)_([^.]+)', filename)
|
|
534
|
+
if match:
|
|
535
|
+
stem_type = match.group(1)
|
|
536
|
+
model_name = match.group(2)
|
|
537
|
+
else:
|
|
538
|
+
self.logger.warning(f"Could not parse stem type and model from filename: {filename}")
|
|
539
|
+
continue
|
|
540
|
+
|
|
541
|
+
# Find the matching backing vocals model
|
|
542
|
+
matching_bv_model = None
|
|
543
|
+
for bv_model in self.backing_vocals_models:
|
|
544
|
+
if model_name == bv_model or bv_model.startswith(model_name) or model_name.startswith(bv_model.split('.')[0]):
|
|
545
|
+
matching_bv_model = bv_model
|
|
546
|
+
break
|
|
547
|
+
|
|
548
|
+
if matching_bv_model:
|
|
549
|
+
if matching_bv_model not in result:
|
|
550
|
+
result[matching_bv_model] = {}
|
|
551
|
+
|
|
552
|
+
if stem_type == "Vocals":
|
|
553
|
+
target_path = os.path.join(stems_dir, f"{artist_title} (Lead Vocals {matching_bv_model}).{self.lossless_output_format}")
|
|
554
|
+
shutil.move(file_path, target_path)
|
|
555
|
+
result[matching_bv_model]["lead_vocals"] = target_path
|
|
556
|
+
elif stem_type == "Instrumental":
|
|
557
|
+
target_path = os.path.join(stems_dir, f"{artist_title} (Backing Vocals {matching_bv_model}).{self.lossless_output_format}")
|
|
558
|
+
shutil.move(file_path, target_path)
|
|
559
|
+
result[matching_bv_model]["backing_vocals"] = target_path
|
|
560
|
+
|
|
561
|
+
return result
|
|
562
|
+
|
|
245
563
|
def _create_stems_directory(self, track_output_dir):
|
|
246
564
|
stems_dir = os.path.join(track_output_dir, "stems")
|
|
247
565
|
os.makedirs(stems_dir, exist_ok=True)
|
karaoke_gen/karaoke_gen.py
CHANGED
|
@@ -566,16 +566,16 @@ class KaraokePrep:
|
|
|
566
566
|
"instrumental": instrumental_path,
|
|
567
567
|
"vocals": None,
|
|
568
568
|
}
|
|
569
|
+
elif "separated_audio" not in processed_track or not processed_track["separated_audio"]:
|
|
570
|
+
# Only run separation if it wasn't already done in parallel processing
|
|
571
|
+
self.logger.info(f"Separation was not completed in parallel processing, running separation for track: {self.title} by {self.artist}")
|
|
572
|
+
# Delegate to AudioProcessor (called directly, not in thread here)
|
|
573
|
+
separation_results = self.audio_processor.process_audio_separation(
|
|
574
|
+
audio_file=processed_track["input_audio_wav"], artist_title=artist_title, track_output_dir=track_output_dir
|
|
575
|
+
)
|
|
576
|
+
processed_track["separated_audio"] = separation_results
|
|
569
577
|
else:
|
|
570
|
-
|
|
571
|
-
if not self.skip_separation:
|
|
572
|
-
self.logger.info(f"Separating audio for track: {self.title} by {self.artist}")
|
|
573
|
-
# Delegate to AudioProcessor (called directly, not in thread here)
|
|
574
|
-
separation_results = self.audio_processor.process_audio_separation(
|
|
575
|
-
audio_file=processed_track["input_audio_wav"], artist_title=artist_title, track_output_dir=track_output_dir
|
|
576
|
-
)
|
|
577
|
-
processed_track["separated_audio"] = separation_results
|
|
578
|
-
# We don't need an else here, if skip_separation is true, separated_audio remains the default empty dict
|
|
578
|
+
self.logger.info("Audio separation was already completed in parallel processing, skipping duplicate separation.")
|
|
579
579
|
|
|
580
580
|
self.logger.info("Script finished, audio downloaded, lyrics fetched and audio separated!")
|
|
581
581
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: karaoke-gen
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.61.0
|
|
4
4
|
Summary: Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens.
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Andrew Beveridge
|
|
@@ -72,6 +72,47 @@ Karaoke Generator is a comprehensive tool for creating high-quality karaoke vide
|
|
|
72
72
|
pip install karaoke-gen
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
## Remote Audio Separation 🌐
|
|
76
|
+
|
|
77
|
+
Karaoke Generator now supports remote audio separation using the Audio Separator API. This allows you to offload the compute-intensive audio separation to a remote GPU server while keeping the rest of the workflow local.
|
|
78
|
+
|
|
79
|
+
### Benefits of Remote Processing
|
|
80
|
+
- **Save Local Resources**: No more laptop CPU/GPU consumption during separation
|
|
81
|
+
- **Faster Processing**: GPU-accelerated separation on dedicated hardware
|
|
82
|
+
- **Cost Effective**: ~$0.019 per separation job on Modal.com (with $30/month free credits)
|
|
83
|
+
- **Multiple Models**: Process with multiple separation models efficiently
|
|
84
|
+
|
|
85
|
+
### Setup Remote Processing
|
|
86
|
+
|
|
87
|
+
1. **Deploy Audio Separator API** (using Modal.com):
|
|
88
|
+
```bash
|
|
89
|
+
pip install modal
|
|
90
|
+
modal setup
|
|
91
|
+
modal deploy audio_separator/remote/deploy_modal.py
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
2. **Set Environment Variable**:
|
|
95
|
+
```bash
|
|
96
|
+
export AUDIO_SEPARATOR_API_URL="https://USERNAME--audio-separator-api.modal.run"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
3. **Run Karaoke Generator Normally**:
|
|
100
|
+
```bash
|
|
101
|
+
karaoke-gen "Rick Astley" "Never Gonna Give You Up"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The tool will automatically detect the `AUDIO_SEPARATOR_API_URL` environment variable and use remote processing instead of local separation. If the remote API is unavailable, it will gracefully fall back to local processing.
|
|
105
|
+
|
|
106
|
+
### Remote vs Local Processing
|
|
107
|
+
|
|
108
|
+
| Aspect | Remote Processing | Local Processing |
|
|
109
|
+
|--------|------------------|------------------|
|
|
110
|
+
| **Resource Usage** | Minimal local CPU/GPU | High local CPU/GPU |
|
|
111
|
+
| **Processing Time** | ~2-5 minutes | ~15-45 minutes |
|
|
112
|
+
| **Cost** | ~$0.019 per job | Free (but uses local resources) |
|
|
113
|
+
| **Requirements** | Internet connection | Local GPU recommended |
|
|
114
|
+
| **Setup** | One-time API deployment | Audio separator models download |
|
|
115
|
+
|
|
75
116
|
## Quick Start
|
|
76
117
|
|
|
77
118
|
```bash
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
karaoke_gen/__init__.py,sha256=ViryQjs8ALc8A7mqJGHu028zajF5-Za_etFagXlo6kk,269
|
|
2
|
-
karaoke_gen/audio_processor.py,sha256=
|
|
2
|
+
karaoke_gen/audio_processor.py,sha256=XMQcEUgLCcMbh4R3onZF4nPezWRFx4JYRk-k3RTUNPk,36901
|
|
3
3
|
karaoke_gen/config.py,sha256=I3h-940ZXvbrCNq_xcWHPMIB76cl-VNQYcK7-qgB-YI,6833
|
|
4
4
|
karaoke_gen/file_handler.py,sha256=c86-rGF7Fusl0uEIZFnreT7PJfK7lmUaEgauU8BBzjY,10024
|
|
5
5
|
karaoke_gen/karaoke_finalise/__init__.py,sha256=HqZ7TIhgt_tYZ-nb_NNCaejWAcF_aK-7wJY5TaW_keM,46
|
|
6
6
|
karaoke_gen/karaoke_finalise/karaoke_finalise.py,sha256=KNuekKG5p4QF5D_RuTmwgcFU_S4KLu2jhSw12Endr7g,84901
|
|
7
|
-
karaoke_gen/karaoke_gen.py,sha256=
|
|
7
|
+
karaoke_gen/karaoke_gen.py,sha256=o2EaFgnDlP3GaKMjLzABNfq--Ey6z_pS6fg5FBB76Ts,38182
|
|
8
8
|
karaoke_gen/lyrics_processor.py,sha256=eUyu0d1OZyWwmpyNCBTKrV1grNzbZ91pFIXnz7le04k,14203
|
|
9
9
|
karaoke_gen/metadata.py,sha256=TprFzWj-iJ7ghrXlHFMPzzqzuHzWeNvs3zGaND-z9Ds,6503
|
|
10
10
|
karaoke_gen/resources/AvenirNext-Bold.ttf,sha256=YxgKz2OP46lwLPCpIZhVa8COi_9KRDSXw4n8dIHHQSs,327048
|
|
@@ -16,8 +16,8 @@ karaoke_gen/utils/__init__.py,sha256=FpOHyeBRB06f3zMoLBUJHTDZACrabg-DoyBTxNKYyNY
|
|
|
16
16
|
karaoke_gen/utils/bulk_cli.py,sha256=uqAHnlidY-f_RhsQIHqZDnrznWRKhqpEDX2uiR1CUQs,18841
|
|
17
17
|
karaoke_gen/utils/gen_cli.py,sha256=sAZ-sau_3dI2hNBOZfiZqJjRf_cJFtuvZLy1V6URcxM,35688
|
|
18
18
|
karaoke_gen/video_generator.py,sha256=B7BQBrjkyvk3L3sctnPXnvr1rzkw0NYx5UCAl0ZiVx0,18464
|
|
19
|
-
karaoke_gen-0.
|
|
20
|
-
karaoke_gen-0.
|
|
21
|
-
karaoke_gen-0.
|
|
22
|
-
karaoke_gen-0.
|
|
23
|
-
karaoke_gen-0.
|
|
19
|
+
karaoke_gen-0.61.0.dist-info/LICENSE,sha256=81R_4XwMZDODHD7JcZeUR8IiCU8AD7Ajl6bmwR9tYDk,1074
|
|
20
|
+
karaoke_gen-0.61.0.dist-info/METADATA,sha256=zLoiEUouh10OEnyl1KRIDGkYJq9RuqADijSWmOmIm1k,7345
|
|
21
|
+
karaoke_gen-0.61.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
22
|
+
karaoke_gen-0.61.0.dist-info/entry_points.txt,sha256=IZY3O8i7m-qkmPuqgpAcxiS2fotNc6hC-CDWvNmoUEY,107
|
|
23
|
+
karaoke_gen-0.61.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|