Treatment synthesize

ml/remote/tts::synthesize


Configuration

⬡ tts: ml/remote/tts::RemoteTts

Inputs

⇥ text: Stream<string>

Outputs

↦ audio: Stream<byte>
↦ error: Stream<string>
↦ failed: Stream<void>


Synthesize speech audio from text using a remote text-to-speech service.

For each string received on text, sends a synthesis request to the configured provider and emits the resulting audio bytes on audio (MP3 format for ElevenLabs). If the request fails, failed and error are emitted instead.

graph LR
     T("synthesize()")
     X["🟩 🟩 …"] -->|text|  T
     T -->|audio|  A["🟩 🟩 🟩 🟩 …"]
     T -->|failed| F["🟩 🟩 …"]
     T -->|error|  E["🟩 🟩 …"]

     style X fill:#ffff,stroke:#ffff
     style A fill:#ffff,stroke:#ffff
     style F fill:#ffff,stroke:#ffff
     style E fill:#ffff,stroke:#ffff
use ml/remote/tts::RemoteTts
use ml/remote/tts::synthesize

treatment example()
  model tts: RemoteTts(
    backend = "elevenlabs",
    api_key = "...",
    voice   = "JBFqnCBsd6RMkjVDRZzb"
  )
  input  text:  Stream<string>
  output audio: Stream<byte>
{
    synthesize[tts=tts]()
    Self.text -> synthesize.text,audio -> Self.audio
}