Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions tests/integration/test_tts_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@ def test_tts_with_different_models(self, client, save_audio):
models = get_args(Model)

for model in models:
try:
audio = client.tts.convert(text=f"Testing model {model}", model=model)
assert len(audio) > 0, f"Failed for model: {model}"

# Write to output directory
save_audio(audio, f"test_model_{model}.mp3")
except Exception as e:
# Some models might not be available
pytest.skip(f"Model {model} not available: {e}")
audio = client.tts.convert(text=f"Testing model {model}", model=model)
assert len(audio) > 0, f"Failed for model: {model}"

# Write to output directory
save_audio(audio, f"test_model_{model}.mp3")

def test_tts_longer_text(self, client, save_audio):
"""Test TTS with longer text."""
Expand Down
41 changes: 41 additions & 0 deletions tests/integration/test_tts_websocket_integration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""Integration tests for TTS WebSocket streaming functionality."""

from typing import get_args

import pytest

from fishaudio import WebSocketOptions
from fishaudio.types import Prosody, TTSConfig, TextEvent, FlushEvent
from fishaudio.types.shared import Model
from .conftest import TEST_REFERENCE_ID


Expand Down Expand Up @@ -31,6 +34,21 @@ def text_stream():
# Save the audio
save_audio(audio_chunks, "test_websocket_streaming.mp3")

def test_websocket_streaming_with_different_models(self, client, save_audio):
"""Test WebSocket streaming with different models."""
models = get_args(Model)

for model in models:

def text_stream():
yield f"Testing model {model} via WebSocket."

audio_chunks = list(client.tts.stream_websocket(text_stream(), model=model))
Comment thread
twangodev marked this conversation as resolved.
assert len(audio_chunks) > 0, f"Failed for model: {model}"

# Write to output directory
save_audio(audio_chunks, f"test_websocket_model_{model}.mp3")

def test_websocket_streaming_with_wav_format(self, client, save_audio):
"""Test WebSocket streaming with WAV format."""
config = TTSConfig(format="wav", chunk_length=200)
Expand Down Expand Up @@ -195,6 +213,29 @@ async def text_stream():

save_audio(audio_chunks, "test_async_websocket_streaming.mp3")

@pytest.mark.asyncio
async def test_async_websocket_streaming_with_different_models(
self, async_client, save_audio
):
"""Test async WebSocket streaming with different models."""
models = get_args(Model)

for model in models:

async def text_stream():
yield f"Testing model {model} via async WebSocket."

audio_chunks = []
async for chunk in async_client.tts.stream_websocket(
text_stream(), model=model
Comment thread
twangodev marked this conversation as resolved.
):
audio_chunks.append(chunk)

assert len(audio_chunks) > 0, f"Failed for model: {model}"

# Write to output directory
save_audio(audio_chunks, f"test_async_websocket_model_{model}.mp3")

@pytest.mark.asyncio
async def test_async_websocket_streaming_with_format(
self, async_client, save_audio
Expand Down
Loading