From 5de3cace3be853e6b8a9512f9ac4c701c61ada47 Mon Sep 17 00:00:00 2001 From: Fireblade Date: Sat, 22 Feb 2025 15:17:28 -0500 Subject: [PATCH] Fix some tests and allow running the docker container offline --- Test.py | 2 +- api/tests/test_audio_service.py | 10 +++++----- docker/scripts/entrypoint.sh | 2 +- start-cpu.sh | 2 +- start-gpu.sh | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Test.py b/Test.py index d5c1cf2..b1db365 100644 --- a/Test.py +++ b/Test.py @@ -23,7 +23,7 @@ text="""Delving into the Abyss: A Deeper Exploration of Meaning in 5 Seconds of 5 Seconds of Summer, initially perceived as purveyors of upbeat, radio-friendly pop-punk, embarked on a significant artistic evolution with their album Sounds Good Feels Good. Among its tracks, "Jet Black Heart" stands out as a powerful testament to this shift, moving beyond catchy melodies and embracing a darker, more emotionally complex sound. Released in 2015, the song transcends the typical themes of youthful exuberance and romantic angst, instead plunging into the depths of personal turmoil and the corrosive effects of inner darkness on interpersonal relationships. "Jet Black Heart" is not merely a song about heartbreak; it is a raw and vulnerable exploration of internal struggle, self-destructive patterns, and the precarious flicker of hope that persists even in the face of profound emotional chaos.""" -Type="aac" +Type="wav" response = requests.post( diff --git a/api/tests/test_audio_service.py b/api/tests/test_audio_service.py index 4afc345..ca2d25d 100644 --- a/api/tests/test_audio_service.py +++ b/api/tests/test_audio_service.py @@ -32,7 +32,7 @@ async def test_convert_to_wav(sample_audio): audio_data, sample_rate = sample_audio # Write and finalize in one step for WAV audio_chunk = await AudioService.convert_audio( - AudioChunk(audio_data), sample_rate, "wav", is_first_chunk=True, is_last_chunk=True + AudioChunk(audio_data), sample_rate, "wav", is_first_chunk=True, is_last_chunk=False ) assert isinstance(audio_chunk.output, bytes) assert isinstance(audio_chunk, AudioChunk) @@ -85,11 +85,11 @@ async def test_convert_to_flac(sample_audio): @pytest.mark.asyncio -async def test_convert_to_m4a(sample_audio): +async def test_convert_to_aac(sample_audio): """Test converting to M4A format""" audio_data, sample_rate = sample_audio audio_chunk = await AudioService.convert_audio( - AudioChunk(audio_data), sample_rate, "m4a" + AudioChunk(audio_data), sample_rate, "aac" ) assert isinstance(audio_chunk.output, bytes) assert isinstance(audio_chunk, AudioChunk) @@ -127,7 +127,7 @@ async def test_normalization_wav(sample_audio): large_audio = audio_data * 1e5 # Write and finalize in one step for WAV audio_chunk = await AudioService.convert_audio( - AudioChunk(large_audio), sample_rate, "wav", is_first_chunk=True, is_last_chunk=True + AudioChunk(large_audio), sample_rate, "wav", is_first_chunk=True ) assert isinstance(audio_chunk.output, bytes) assert isinstance(audio_chunk, AudioChunk) @@ -165,7 +165,7 @@ async def test_different_sample_rates(sample_audio): for rate in sample_rates: audio_chunk = await AudioService.convert_audio( - AudioChunk(audio_data), rate, "wav", is_first_chunk=True, is_last_chunk=True + AudioChunk(audio_data), rate, "wav", is_first_chunk=True ) assert isinstance(audio_chunk.output, bytes) assert isinstance(audio_chunk, AudioChunk) diff --git a/docker/scripts/entrypoint.sh b/docker/scripts/entrypoint.sh index ca72910..a578495 100644 --- a/docker/scripts/entrypoint.sh +++ b/docker/scripts/entrypoint.sh @@ -5,4 +5,4 @@ if [ "$DOWNLOAD_MODEL" = "true" ]; then python download_model.py --output api/src/models/v1_0 fi -exec uv run --extra $DEVICE python -m uvicorn api.src.main:app --host 0.0.0.0 --port 8880 --log-level debug \ No newline at end of file +exec uv run --extra $DEVICE --no-sync python -m uvicorn api.src.main:app --host 0.0.0.0 --port 8880 --log-level debug \ No newline at end of file diff --git a/start-cpu.sh b/start-cpu.sh index 1af531d..651f645 100755 --- a/start-cpu.sh +++ b/start-cpu.sh @@ -14,4 +14,4 @@ export WEB_PLAYER_PATH=$PROJECT_ROOT/web # Run FastAPI with CPU extras using uv run # Note: espeak may still require manual installation, uv pip install -e ".[cpu]" -uv run uvicorn api.src.main:app --host 0.0.0.0 --port 8880 +uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 diff --git a/start-gpu.sh b/start-gpu.sh index d932df4..b079978 100755 --- a/start-gpu.sh +++ b/start-gpu.sh @@ -13,4 +13,4 @@ export WEB_PLAYER_PATH=$PROJECT_ROOT/web # Run FastAPI with GPU extras using uv run uv pip install -e ".[gpu]" -uv run uvicorn api.src.main:app --host 0.0.0.0 --port 8880 +uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880