Octoroom.Agent.Processors.TTS (octoroom_agents v0.1.0)

Copy Markdown View Source

Speaks Text frames.

For each chunk it pushes TTSStarted (first chunk of a response), TTSText, OutputAudio as the audio streams in, and TTSStopped when the response is done. Chunks that arrive while one is synthesizing are queued and sent as one request, so the voice keeps its prosody across sentences. LLMResponseEnd and End wait until the queued audio is out.

Options are Octoroom.Agent.TTS's: :provider and :model (both needed), :voice, :api_key and the provider's own, with :output_sample_rate as the provider's :sample_rate. It connects the provider once (Octoroom.Agent.TTS.connect/2), for those that keep a connection. Also :chunk_timeout_ms, and :synthesize, a fn text, on_audio -> :ok | {:error, reason} end that replaces the provider (for tests).