Try to fix confirm and interrupt
This commit is contained in:
59
backend/tests/test_service_factory.py
Normal file
59
backend/tests/test_service_factory.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from models import AssistantConfig
|
||||
from services.pipecat.service_factory import (
|
||||
HTTP_TTS_STOP_FRAME_TIMEOUT_S,
|
||||
WEBSOCKET_TTS_STOP_FRAME_TIMEOUT_S,
|
||||
create_tts,
|
||||
)
|
||||
|
||||
|
||||
class TTSServiceFactoryTest(unittest.TestCase):
|
||||
def test_http_tts_keeps_wider_audio_chunk_timeout(self):
|
||||
config = AssistantConfig(
|
||||
tts_interface_type="openai-tts",
|
||||
tts_model="test-model",
|
||||
voice="test-voice",
|
||||
tts_api_key="test-key",
|
||||
tts_base_url="https://tts.example.test/v1",
|
||||
)
|
||||
|
||||
with patch(
|
||||
"services.pipecat.service_factory.OpenAITTSService"
|
||||
) as service_type:
|
||||
create_tts(config)
|
||||
|
||||
self.assertEqual(HTTP_TTS_STOP_FRAME_TIMEOUT_S, 3.0)
|
||||
self.assertEqual(
|
||||
service_type.call_args.kwargs["stop_frame_timeout_s"],
|
||||
HTTP_TTS_STOP_FRAME_TIMEOUT_S,
|
||||
)
|
||||
|
||||
def test_websocket_tts_keeps_short_completion_fallback(self):
|
||||
config = AssistantConfig(
|
||||
tts_interface_type="xfyun-tts",
|
||||
voice="test-voice",
|
||||
tts_secrets={
|
||||
"appId": "test-app",
|
||||
"apiKey": "test-key",
|
||||
"apiSecret": "test-secret",
|
||||
},
|
||||
)
|
||||
|
||||
with patch(
|
||||
"services.pipecat.service_factory.XfyunTTSService"
|
||||
) as service_type:
|
||||
create_tts(config)
|
||||
|
||||
self.assertEqual(WEBSOCKET_TTS_STOP_FRAME_TIMEOUT_S, 1.0)
|
||||
self.assertEqual(
|
||||
service_type.call_args.kwargs["stop_frame_timeout_s"],
|
||||
WEBSOCKET_TTS_STOP_FRAME_TIMEOUT_S,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user