Behaviour for voice workflows.
A workflow processes transcribed text and generates text responses to be synthesized as speech.
Example
defmodule MyWorkflow do
@behaviour Codex.Voice.Workflow
defstruct [:context]
@impl true
def run(%__MODULE__{} = _workflow, transcription) do
# Return a stream of text responses
["I heard you say: #{transcription}"]
end
@impl true
def on_start(%__MODULE__{}) do
["Hello! I'm ready to help."]
end
end
Summary
Callbacks
Called at the start of a multi-turn session.
Process a transcription and return text responses.
Callbacks
@callback on_start(workflow :: struct()) :: Enumerable.t()
Called at the start of a multi-turn session.
Override to provide an initial greeting. Returns an empty list by default.
@callback run(workflow :: struct(), transcription :: String.t()) :: Enumerable.t()
Process a transcription and return text responses.
The returned value should be an enumerable of strings that will be synthesized as speech.