Skip to content

Commit 886026c

Browse files
authored
Merge branch 'main' into dependabot/uv/ty-0.0.21
2 parents 5460931 + cc912a6 commit 886026c

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

samples/jfk.wav

344 KB
Binary file not shown.

tests/integration/test_asr_integration.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
"""Integration tests for ASR functionality."""
22

3+
from pathlib import Path
4+
35
import pytest
46

57
from fishaudio.types import ASRResponse, TTSConfig
68

9+
SAMPLES_DIR = Path(__file__).resolve().parents[2] / "samples"
10+
711

812
class TestASRIntegration:
913
"""Test ASR with real API."""
@@ -45,6 +49,61 @@ def test_asr_without_timestamps(self, client, sample_audio):
4549
# Segments might still be present but potentially empty or without timing
4650

4751

52+
class TestASRFromFileIntegration:
53+
"""Test ASR using a sample audio file with known content."""
54+
55+
@pytest.fixture
56+
def jfk_audio(self):
57+
"""Load the JFK sample audio file."""
58+
return (SAMPLES_DIR / "jfk.wav").read_bytes()
59+
60+
def test_asr_from_file(self, client, jfk_audio):
61+
"""Test transcription of a known audio file."""
62+
result = client.asr.transcribe(audio=jfk_audio, language="en")
63+
64+
assert isinstance(result, ASRResponse)
65+
assert result.duration > 0
66+
# JFK's famous quote
67+
text = result.text.lower()
68+
assert "ask not what your country can do for you" in text
69+
70+
def test_asr_from_file_with_timestamps(self, client, jfk_audio):
71+
"""Test transcription with timestamps from a known audio file."""
72+
result = client.asr.transcribe(audio=jfk_audio, language="en")
73+
74+
assert len(result.segments) > 0
75+
for segment in result.segments:
76+
assert segment.text
77+
assert segment.start >= 0
78+
assert segment.end > segment.start
79+
80+
def test_asr_from_file_without_timestamps(self, client, jfk_audio):
81+
"""Test transcription without timestamps from a known audio file."""
82+
result = client.asr.transcribe(audio=jfk_audio, include_timestamps=False)
83+
84+
assert isinstance(result, ASRResponse)
85+
assert result.text
86+
87+
88+
class TestAsyncASRFromFileIntegration:
89+
"""Test async ASR using a sample audio file."""
90+
91+
@pytest.fixture
92+
def jfk_audio(self):
93+
"""Load the JFK sample audio file."""
94+
return (SAMPLES_DIR / "jfk.wav").read_bytes()
95+
96+
@pytest.mark.asyncio
97+
async def test_async_asr_from_file(self, async_client, jfk_audio):
98+
"""Test async transcription of a known audio file."""
99+
result = await async_client.asr.transcribe(audio=jfk_audio, language="en")
100+
101+
assert isinstance(result, ASRResponse)
102+
assert result.text
103+
assert result.duration > 0
104+
assert "ask not what your country can do for you" in result.text.lower()
105+
106+
48107
class TestAsyncASRIntegration:
49108
"""Test async ASR with real API."""
50109

tests/unit/test_tts.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ def test_convert_with_different_backend(self, tts_client, mock_client_wrapper):
201201
call_args = mock_client_wrapper.request.call_args
202202
assert call_args[1]["headers"]["model"] == "s1"
203203

204+
def test_convert_unknown_model_passed_through_to_header(
205+
self, tts_client, mock_client_wrapper
206+
):
207+
"""Test that an unknown model name is passed through to the HTTP header as-is."""
208+
mock_response = Mock()
209+
mock_response.iter_bytes.return_value = iter([b"audio"])
210+
mock_client_wrapper.request.return_value = mock_response
211+
212+
# Pass a model name that doesn't exist in the Model Literal type
213+
tts_client.convert(text="Hello", model="speech-99-nonexistent")
214+
215+
# Verify the unknown model name still ends up in the request header
216+
call_args = mock_client_wrapper.request.call_args
217+
assert call_args[1]["headers"]["model"] == "speech-99-nonexistent"
218+
204219
def test_convert_with_prosody(self, tts_client, mock_client_wrapper):
205220
"""Test TTS with prosody settings."""
206221
mock_response = Mock()

0 commit comments

Comments
 (0)