Spaces:
Running
Running
File size: 711 Bytes
7cc81cb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from __future__ import annotations
import shutil
import wave
import pytest
from app.services.ffprobe_service import FFprobeService
@pytest.mark.skipif(shutil.which("ffprobe") is None, reason="ffprobe is not installed")
async def test_ffprobe_returns_audio_metadata(settings, tmp_path) -> None:
audio = tmp_path / "tone.wav"
with wave.open(str(audio), "wb") as stream:
stream.setnchannels(1)
stream.setsampwidth(2)
stream.setframerate(8000)
stream.writeframes(b"\x00\x00" * 8000)
metadata = await FFprobeService(settings).probe(audio)
assert metadata["duration"] == pytest.approx(1.0, abs=0.01)
assert metadata["audio_streams"][0]["codec"] == "pcm_s16le"
|