26 lines
843 B
Python
26 lines
843 B
Python
import base64
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
from openrouter_client import TRANSCRIPTION_MODELS, _audio_format, _build_transcription_payload
|
|
|
|
|
|
def test_audio_format_defaults_to_wav_when_missing_suffix(tmp_path: Path):
|
|
path = tmp_path / "recording"
|
|
path.write_bytes(b"abc")
|
|
assert _audio_format(str(path)) == "wav"
|
|
|
|
|
|
def test_build_transcription_payload_uses_base64_json_shape(tmp_path: Path):
|
|
path = tmp_path / "meeting.wav"
|
|
path.write_bytes(b"RIFFdemo")
|
|
|
|
payload = _build_transcription_payload(str(path), TRANSCRIPTION_MODELS[0])
|
|
|
|
assert payload["model"] == "openai/gpt-4o-mini-transcribe"
|
|
assert payload["input_audio"]["format"] == "wav"
|
|
assert payload["input_audio"]["data"] == base64.b64encode(b"RIFFdemo").decode("ascii")
|