Lock MVP voice (Michael, native settings); native /tts route

This commit is contained in:
Audiobook Producer
2026-10-17 16:44:28 -05:00
parent 444cee7f76
commit ca5592b964
4 changed files with 136 additions and 6 deletions
+15 -1
View File
@@ -67,7 +67,7 @@ class StubHandler(http.server.BaseHTTPRequestHandler):
def do_POST(self):
body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
StubHandler.seen.append((self.path, body))
if self.path.endswith("/audio/speech"):
if self.path.endswith("/audio/speech") or self.path == "/tts":
with tempfile.TemporaryDirectory() as d:
p = os.path.join(d, "x.wav")
test_piece(p, 130, 1, 0.1)
@@ -100,6 +100,8 @@ class ClientTests(unittest.TestCase):
def cfg(self):
c = json.loads(json.dumps(CFG))
c["voice"]["endpoint"] = self.url + "/v1/audio/speech"
c["voice"]["api"] = "openai"
c["voice"]["extra"] = {}
c["llm"].update(endpoint=self.url + "/v1/chat/completions", model="m")
return c
@@ -112,6 +114,18 @@ class ClientTests(unittest.TestCase):
self.assertEqual(body["response_format"], "wav")
self.assertEqual(data[:4], b"RIFF")
def test_locked_voice_uses_native_route_with_locked_settings(self):
StubHandler.seen.clear()
c = json.loads(json.dumps(CFG))
c["voice"]["endpoint"] = self.url + "/tts"
voice.speak(c, "Hello there.")
path, body = StubHandler.seen[0]
self.assertEqual(path, "/tts")
self.assertEqual(body["text"], "Hello there.")
self.assertEqual(body["predefined_voice_id"], "Michael.wav")
self.assertEqual((body["exaggeration"], body["cfg_weight"], body["temperature"], body["seed"], body["chunk_size"]), (0.25, 0.2, 0.6, 7, 240))
self.assertNotIn("speed_factor", body)
def test_sentence_split_keeps_abbreviations(self):
s = voice.sentences('One day Dr. Alexis Carrel sent word. "The world," he said. E. Stanley Jones came.')
self.assertEqual(len(s), 3)