31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""test_qwen_tts_service.py
|
|
|
|
Unit test for QwenTTSService.
|
|
Verifies loading MLX Qwen3-TTS 0.6B model and generating audio frames.
|
|
"""
|
|
|
|
import asyncio
|
|
from qwen_tts_service import QwenTTSService
|
|
from pipecat.frames.frames import TTSAudioRawFrame
|
|
|
|
|
|
async def main():
|
|
print("Testing QwenTTSService with MLX Qwen3-TTS 0.6B...")
|
|
service = QwenTTSService(voice="qwen_jv")
|
|
|
|
frames = []
|
|
async for frame in service.run_tts("Hello! This is a test of Qwen 0.6B TTS service.", context_id="test_ctx"):
|
|
frames.append(frame)
|
|
|
|
assert len(frames) > 0, "No frames generated by QwenTTSService"
|
|
audio_frames = [f for f in frames if isinstance(f, TTSAudioRawFrame)]
|
|
assert len(audio_frames) > 0, "No TTSAudioRawFrame generated"
|
|
|
|
total_bytes = sum(len(f.audio) for f in audio_frames)
|
|
duration_s = total_bytes / (24000 * 2)
|
|
print(f"PASS: Generated {len(audio_frames)} audio frame(s), total {total_bytes} bytes ({duration_s:.2f}s audio at 24kHz)!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|