import asyncio
from kova_tts import AudioResponseFormat
async def main():
async with client.websocket() as ws:
await ws.start_context(
context_id="ctx-1",
voice_id="cal",
model_id="default",
response_format=AudioResponseFormat(encoding="pcm", sample_rate=32000),
)
await ws.send_text("Hello ", context_id="ctx-1")
await ws.send_text("world.", context_id="ctx-1")
await ws.flush(context_id="ctx-1", flush_id="end")
async for frame in ws:
if frame.type == "audio":
print(f"pcm: {len(frame.audio)} bytes")
elif frame.type == "timestamps":
print(frame.timestamps.words)
elif frame.type == "flush_completed" and frame.flush_id == "end":
break
await ws.close_context(context_id="ctx-1")
asyncio.run(main())