30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
"""Emotion -> instruct passthrough in the TTS payload builders (core/tts_helpers.py)."""
|
|
import os
|
|
import tempfile
|
|
import unittest
|
|
|
|
os.environ.setdefault("CONFIG_DIR", tempfile.mkdtemp(prefix="tip-cfg-"))
|
|
|
|
from core.tts_helpers import _tts_request_config, _tts_stream_request_config
|
|
|
|
S = {"tts_url": "http://localhost:9999", "tts_backend": "openai"}
|
|
|
|
|
|
class InstructPayloadTests(unittest.TestCase):
|
|
def test_instruct_is_sent_stripped(self):
|
|
_, p, _ = _tts_request_config("Hi", "DE_M_x", S, instruct=" Speak in an angry tone. ")
|
|
self.assertEqual(p["instruct"], "Speak in an angry tone.")
|
|
_, p, _ = _tts_stream_request_config("Hi", "DE_M_x", S, " angry ")
|
|
self.assertEqual(p["instruct"], "angry")
|
|
|
|
def test_empty_instruct_is_omitted(self):
|
|
for ins in ("", " "):
|
|
_, p, _ = _tts_request_config("Hi", "DE_M_x", S, instruct=ins)
|
|
self.assertNotIn("instruct", p)
|
|
_, p, _ = _tts_stream_request_config("Hi", "DE_M_x", S, ins)
|
|
self.assertNotIn("instruct", p)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|