mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
Fixed logic bug causing duplicate separation
This commit is contained in:
3 files changed
+27
-2
No files matched your search
@@ -496,7 +496,7 @@ class KaraokePrep:
|
||||
# Check if separation_future was the placeholder or a real task
|
||||
# The result index in `results` depends on whether transcription_future existed
|
||||
separation_result_index = 1 if transcription_future else 0
|
||||
if separation_future is not None and not isinstance(separation_future, asyncio.Task) and len(results) > separation_result_index:
|
||||
if separation_future is not None and isinstance(separation_future, asyncio.Task) and len(results) > separation_result_index:
|
||||
self.logger.info("Processing separation results...")
|
||||
try:
|
||||
separation_results = results[separation_result_index]
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-gen"
|
||||
version = "0.62.0"
|
||||
version = "0.62.1"
|
||||
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -373,6 +373,31 @@ class TestAsync:
|
||||
# Assert that the transcription mock WAS called (implicitly via gather)
|
||||
assert mock_transcribe.call_count > 0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_separation_runs_only_once(self, basic_karaoke_gen, temp_dir):
|
||||
"""Verify that audio separation is only run once during parallel processing."""
|
||||
basic_karaoke_gen.input_media = os.path.join(temp_dir, "input.mp4")
|
||||
basic_karaoke_gen.artist = "Test Artist"
|
||||
basic_karaoke_gen.title = "Test Title"
|
||||
basic_karaoke_gen.output_dir = temp_dir
|
||||
|
||||
with open(basic_karaoke_gen.input_media, "w") as f:
|
||||
f.write("mock video content")
|
||||
|
||||
with patch.object(basic_karaoke_gen.file_handler, 'setup_output_paths', return_value=(temp_dir, "Test Artist - Test Title")), \
|
||||
patch.object(basic_karaoke_gen.file_handler, 'copy_input_media', return_value=os.path.join(temp_dir, "copied.mp4")), \
|
||||
patch.object(basic_karaoke_gen.file_handler, 'convert_to_wav', return_value=os.path.join(temp_dir, "converted.wav")), \
|
||||
patch.object(basic_karaoke_gen.file_handler, '_file_exists', return_value=False), \
|
||||
patch.object(basic_karaoke_gen.lyrics_processor, 'transcribe_lyrics', AsyncMock(return_value={'corrected_lyrics_text_filepath': 'lyrics.txt'})), \
|
||||
patch.object(basic_karaoke_gen.audio_processor, 'process_audio_separation', return_value={'instrumental': 'inst.flac'}) as mock_separation, \
|
||||
patch.object(basic_karaoke_gen.video_generator, 'create_title_video'), \
|
||||
patch.object(basic_karaoke_gen.video_generator, 'create_end_video'):
|
||||
|
||||
await basic_karaoke_gen.prep_single_track()
|
||||
|
||||
# The core assertion: was separation called only once?
|
||||
mock_separation.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_shutdown(self, basic_karaoke_gen):
|
||||
"""Test the shutdown signal handler."""
|
||||
|
||||
Reference in new issue
Block a user