Spaces:
Sleeping
Sleeping
Commit
·
4f456d8
1
Parent(s):
05ed2b2
Fix RuntimeError and Test
Browse files- .gitignore +5 -1
- app/audio_utils.py +1 -1
- test/conftest.py +0 -1
- test/test_long_performance.py +1 -1
- test/test_short_and_chunk.py +2 -3
.gitignore
CHANGED
|
@@ -1 +1,5 @@
|
|
| 1 |
-
tests/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
tests/
|
| 2 |
+
.myvenv/
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
.env
|
app/audio_utils.py
CHANGED
|
@@ -48,7 +48,7 @@ def ensure_wav_16k_mono(src_path: str, dest_path: str):
|
|
| 48 |
cmd = f'ffmpeg -v error -y -i "{src_path}" -ar 16000 -ac 1 -acodec pcm_s16le "{dest_path}"'
|
| 49 |
proc = subprocess.run(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 50 |
if proc.returncode != 0:
|
| 51 |
-
raise RuntimeError(f"ffmpeg convert failed: {proc.stderr.decode(errors=
|
| 52 |
return dest_path
|
| 53 |
|
| 54 |
def make_temp_path(suffix=".wav"):
|
|
|
|
| 48 |
cmd = f'ffmpeg -v error -y -i "{src_path}" -ar 16000 -ac 1 -acodec pcm_s16le "{dest_path}"'
|
| 49 |
proc = subprocess.run(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 50 |
if proc.returncode != 0:
|
| 51 |
+
raise RuntimeError(f"ffmpeg convert failed: {proc.stderr.decode(errors='ignore')}")
|
| 52 |
return dest_path
|
| 53 |
|
| 54 |
def make_temp_path(suffix=".wav"):
|
test/conftest.py
CHANGED
|
@@ -4,7 +4,6 @@ from pathlib import Path
|
|
| 4 |
import os
|
| 5 |
import tempfile
|
| 6 |
import re
|
| 7 |
-
|
| 8 |
import pytest
|
| 9 |
|
| 10 |
# helper to synthesize a sine wave (mono) wav file
|
|
|
|
| 4 |
import os
|
| 5 |
import tempfile
|
| 6 |
import re
|
|
|
|
| 7 |
import pytest
|
| 8 |
|
| 9 |
# helper to synthesize a sine wave (mono) wav file
|
test/test_long_performance.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
| 2 |
import time
|
| 3 |
import pytest
|
| 4 |
from pathlib import Path
|
| 5 |
-
from
|
| 6 |
from app.model import transcribe_file
|
| 7 |
|
| 8 |
@pytest.mark.skipif(os.getenv("RUN_LONG_TESTS", "0") != "1", reason="long tests disabled by default")
|
|
|
|
| 2 |
import time
|
| 3 |
import pytest
|
| 4 |
from pathlib import Path
|
| 5 |
+
from conftest import generate_sine_wav
|
| 6 |
from app.model import transcribe_file
|
| 7 |
|
| 8 |
@pytest.mark.skipif(os.getenv("RUN_LONG_TESTS", "0") != "1", reason="long tests disabled by default")
|
test/test_short_and_chunk.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
import os
|
| 2 |
from pathlib import Path
|
| 3 |
import pytest
|
| 4 |
-
|
| 5 |
from app.model import transcribe_file, _split_audio_to_chunks, _merge_transcripts
|
| 6 |
-
from
|
| 7 |
|
| 8 |
def test_short_audio_direct(tmp_path, fake_pipeline):
|
| 9 |
# create short wav: 5s
|
|
@@ -18,7 +17,7 @@ def test_chunk_split_and_merge(tmp_path):
|
|
| 18 |
# Create audio ~75s to force chunking into 3 chunks with (L=30, O=5) -> starts 0,25,50
|
| 19 |
p = tmp_path / "long75.wav"
|
| 20 |
# 75s sine; note: generating >60s may be heavy; for CI shorten if needed
|
| 21 |
-
from
|
| 22 |
generate_sine_wav(str(p), duration_s=75.0)
|
| 23 |
# Use internal split function to inspect chunking
|
| 24 |
chunks = _split_audio_to_chunks(str(p), chunk_length_s=30.0, overlap_s=5.0)
|
|
|
|
| 1 |
import os
|
| 2 |
from pathlib import Path
|
| 3 |
import pytest
|
|
|
|
| 4 |
from app.model import transcribe_file, _split_audio_to_chunks, _merge_transcripts
|
| 5 |
+
from conftest import generate_sine_wav
|
| 6 |
|
| 7 |
def test_short_audio_direct(tmp_path, fake_pipeline):
|
| 8 |
# create short wav: 5s
|
|
|
|
| 17 |
# Create audio ~75s to force chunking into 3 chunks with (L=30, O=5) -> starts 0,25,50
|
| 18 |
p = tmp_path / "long75.wav"
|
| 19 |
# 75s sine; note: generating >60s may be heavy; for CI shorten if needed
|
| 20 |
+
from conftest import generate_sine_wav
|
| 21 |
generate_sine_wav(str(p), duration_s=75.0)
|
| 22 |
# Use internal split function to inspect chunking
|
| 23 |
chunks = _split_audio_to_chunks(str(p), chunk_length_s=30.0, overlap_s=5.0)
|