Skip to content

API Reference parrot_formdesigner.audio.engine

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.audio.engine

View source

Pure audio form session engine (FEAT-649, spec §3 Module 10).

AudioFormSession.handle(event) -> list[Outbound] is a synchronous state machine: it never awaits and performs no I/O. I/O is requested through Outbound request models that the WebSocket adapter performs and answers with *_Done / PlanReady / IOFailed events.

Alias AnswerAccepted

Re-exported from parrot_formdesigner.audio.events.AnswerAccepted.

Alias AnswerCleared

Re-exported from parrot_formdesigner.audio.events.AnswerCleared.

Alias AnswerPayload

Re-exported from parrot_formdesigner.audio.events.AnswerPayload.

Alias AnswerRejected

Re-exported from parrot_formdesigner.audio.events.AnswerRejected.

Alias AnswerSelection

Re-exported from parrot_formdesigner.audio.events.AnswerSelection.

Alias AnswerText

Re-exported from parrot_formdesigner.audio.events.AnswerText.

Alias AnswersReady

Re-exported from parrot_formdesigner.audio.events.AnswersReady.

Alias AudioAnswer

Re-exported from parrot_formdesigner.audio.models.AudioAnswer.

Alias AudioFormManifest

Re-exported from parrot_formdesigner.audio.models.AudioFormManifest.

Class AudioFormSession

Pure audio form state machine — see module docstring.

Parameter Type Default Description
form FormSchema
manifest AudioFormManifest
cfg VoiceFormConfig
narrator Narrator
lexicon Lexicon
state AudioSessionState
llm_cfg LLMValidationConfig | None
clock Callable[[], datetime] | None None

Method AudioFormSession.handle

Dispatch one event; mutate state; return wire messages + I/O requests. Never awaits.

handle(event: InboundEvent) -> list[Outbound]

Parameter Type Default Description
event InboundEvent

Returns: list[Outbound]

Method AudioFormSession.on_start

Record locale/protocol, enter PLANNING and request the first re-plan.

on_start(ev: StartSession) -> list[Outbound]

Parameter Type Default Description
ev StartSession

Returns: list[Outbound]

Method AudioFormSession.on_plan_ready

Adopt the new plan; emit plan deltas; ask the cursor question, or finish.

on_plan_ready(ev: PlanReady) -> list[Outbound]

Parameter Type Default Description
ev PlanReady

Returns: list[Outbound]

Method AudioFormSession.on_audio_frame

Stash the recording (never snapshotted) and request transcription for the cursor field.

on_audio_frame(ev: AudioReceived) -> list[Outbound]

Parameter Type Default Description
ev AudioReceived

Returns: list[Outbound]

Method AudioFormSession.on_transcript

Commands → option match → STT confidence gate → accept / confirm / reject.

on_transcript(ev: TranscriptReady) -> list[Outbound]

Parameter Type Default Description
ev TranscriptReady

Returns: list[Outbound]

Method AudioFormSession.on_value_refined

Drop when stale (no in-flight refine, field or request_id mismatch); else re-normalize and _gate.

on_value_refined(ev: ValueRefined) -> list[Outbound]

Parameter Type Default Description
ev ValueRefined

Returns: list[Outbound]

Method AudioFormSession.on_text

Typed answer for the cursor field.

on_text(ev: AnswerText) -> list[Outbound]

Parameter Type Default Description
ev AnswerText

Returns: list[Outbound]

Method AudioFormSession.on_selection

Selection answer (single or multi) validated against the enabled option values.

on_selection(ev: AnswerSelection) -> list[Outbound]

Parameter Type Default Description
ev AnswerSelection

Returns: list[Outbound]

Method AudioFormSession.on_payload

Payload answer (VISUAL_FALLBACK / structured fields) for the cursor field.

on_payload(ev: AnswerPayload) -> list[Outbound]

Parameter Type Default Description
ev AnswerPayload

Returns: list[Outbound]

Method AudioFormSession.on_confirm

Confirm or discard the pending low-confidence answer.

on_confirm(ev: ConfirmAnswer) -> list[Outbound]

Parameter Type Default Description
ev ConfirmAnswer

Returns: list[Outbound]

Method AudioFormSession.on_blob_stored

Attach the stored recording reference to the (still current) answer version.

on_blob_stored(ev: BlobStored) -> list[Outbound]

Parameter Type Default Description
ev BlobStored

Returns: list[Outbound]

Method AudioFormSession.on_skip

Skip the cursor question unless it is required.

on_skip(ev: SkipQuestion) -> list[Outbound]

Parameter Type Default Description
ev SkipQuestion

Returns: list[Outbound]

Method AudioFormSession.on_back

Move the cursor to a previous question (explicit target or the latest visited one).

on_back(ev: GoBack) -> list[Outbound]

Parameter Type Default Description
ev GoBack

Returns: list[Outbound]

Method AudioFormSession.on_repeat

Re-send the cursor question; no state change.

on_repeat(ev: RepeatQuestion) -> list[Outbound]

Parameter Type Default Description
ev RepeatQuestion

Returns: list[Outbound]

Method AudioFormSession.on_end

End the session immediately and delete every stored recording (S8).

on_end(ev: EndSession) -> list[Outbound]

Parameter Type Default Description
ev EndSession

Returns: list[Outbound]

Method AudioFormSession.on_ping

Keep-alive.

on_ping(ev: Ping) -> list[Outbound]

Parameter Type Default Description
ev Ping

Returns: list[Outbound]

Method AudioFormSession.on_io_failed

Map a failed I/O request onto a client-visible error (recording I/O failures are non-fatal).

on_io_failed(ev: IOFailed) -> list[Outbound]

Parameter Type Default Description
ev IOFailed

Returns: list[Outbound]

Method AudioFormSession.on_plausibility_done

Merge the (full or delta) report; flag low confidence once per answer version; (re)enter REVIEW.

on_plausibility_done(ev: PlausibilityDone) -> list[Outbound]

Parameter Type Default Description
ev PlausibilityDone

Returns: list[Outbound]

Method AudioFormSession.on_review_confirm

Confirmed → SUBMITTING + Submit (low confidence never blocks); not confirmed → re-read the review.

on_review_confirm(ev: ReviewConfirm) -> list[Outbound]

Parameter Type Default Description
ev ReviewConfirm

Returns: list[Outbound]

Method AudioFormSession.on_review_edit

Re-ask one field from the review; its acceptance returns to the review via a delta plausibility batch.

on_review_edit(ev: ReviewEdit) -> list[Outbound]

Parameter Type Default Description
ev ReviewEdit

Returns: list[Outbound]

Method AudioFormSession.on_review_prompt_answer

Spoken turn during REVIEW: confirm phrases → submit; "change N"/label → edit; else re-read.

on_review_prompt_answer(ev: TranscriptReady) -> list[Outbound]

Parameter Type Default Description
ev TranscriptReady

Returns: list[Outbound]

Method AudioFormSession.snapshot

Serializable state for AudioSessionStore (no audio bytes, no trusted plausibility).

Sensitive answers keep only their evidence shell (value and transcript dropped, S8), so a resumed session re-asks them. The skipped optional fields travel under answer_meta["_skipped"]. revision is owned by the store (compare-and-set) and left at 0.

snapshot() -> AudioSnapshot

Returns: AudioSnapshot

Method AudioFormSession.from_snapshot

Rebuild a session shell from a snapshot; the caller then feeds StartSession(resume_session_id=…).

deps are the regular constructor arguments (state carries the current caller identity). The saved data is validated and applied by on_start so identity checks see both sides.

from_snapshot(snap: AudioSnapshot, **deps: Any) -> 'AudioFormSession'

Parameter Type Default Description
snap AudioSnapshot
**deps Any {}

Returns: 'AudioFormSession'

Method AudioFormSession.on_submit_done

FormComplete on success (AnswersReady for client_data); ValidationErrors + re-ask first failing field otherwise.

ev.outcome is either a dumped SubmitOutcome (success: submission_id / stored_in) or a dict carrying errors ({field_id: [messages]}) for a deterministic validation rejection.

on_submit_done(ev: SubmitDone) -> list[Outbound]

Parameter Type Default Description
ev SubmitDone

Returns: list[Outbound]

Alias AudioQuestion

Re-exported from parrot_formdesigner.audio.models.AudioQuestion.

Alias AudioReceived

Re-exported from parrot_formdesigner.audio.events.AudioReceived.

Alias AudioSessionState

Re-exported from parrot_formdesigner.audio.models.AudioSessionState.

Alias AudioSnapshot

Re-exported from parrot_formdesigner.audio.session_store.AudioSnapshot.

Alias BlobStored

Re-exported from parrot_formdesigner.audio.events.BlobStored.

Alias CommandAck

Re-exported from parrot_formdesigner.audio.events.CommandAck.

Alias ConfirmAnswer

Re-exported from parrot_formdesigner.audio.events.ConfirmAnswer.

Alias ConfirmRequest

Re-exported from parrot_formdesigner.audio.events.ConfirmRequest.

Alias DeleteBlob

Re-exported from parrot_formdesigner.audio.events.DeleteBlob.

Alias EndSession

Re-exported from parrot_formdesigner.audio.events.EndSession.

Class EngineError

Programming error inside the engine (never raised for client input).

Parameter Type Default Description
code str
message str ''

Alias Error

Re-exported from parrot_formdesigner.audio.events.Error.

Alias FieldType

Re-exported from parrot_formdesigner.core.types.FieldType.

Alias FieldVoiceMeta

Re-exported from parrot_formdesigner.core.voice.FieldVoiceMeta.

Alias FormComplete

Re-exported from parrot_formdesigner.audio.events.FormComplete.

Alias FormField

Re-exported from parrot_formdesigner.core.schema.FormField.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Alias GoBack

Re-exported from parrot_formdesigner.audio.events.GoBack.

Alias IOFailed

Re-exported from parrot_formdesigner.audio.events.IOFailed.

Alias InboundEvent

Re-exported from parrot_formdesigner.audio.events.InboundEvent.

Alias LLMValidationConfig

Re-exported from parrot_formdesigner.core.llm_validation.LLMValidationConfig.

Alias Lexicon

Re-exported from parrot_formdesigner.audio.narration.lexicon.Lexicon.

Alias NOT_EXAMINED_MAX_FIELDS

Re-exported from parrot_formdesigner.core.llm_validation.NOT_EXAMINED_MAX_FIELDS.

Alias Narrator

Re-exported from parrot_formdesigner.audio.narration.engine.Narrator.

Alias NormalizeContext

Re-exported from parrot_formdesigner.audio.normalize.NormalizeContext.

Alias NormalizeResult

Re-exported from parrot_formdesigner.audio.normalize.NormalizeResult.

Alias OptionMatch

Re-exported from parrot_formdesigner.audio.models.OptionMatch.

Alias Outbound

Re-exported from parrot_formdesigner.audio.events.Outbound.

Alias Phase

Re-exported from parrot_formdesigner.audio.models.Phase.

Alias Ping

Re-exported from parrot_formdesigner.audio.events.Ping.

Alias PlanDelta

Re-exported from parrot_formdesigner.audio.planner.PlanDelta.

Alias PlanReady

Re-exported from parrot_formdesigner.audio.events.PlanReady.

Alias PlanUpdated

Re-exported from parrot_formdesigner.audio.events.PlanUpdated.

Alias PlausibilityDone

Re-exported from parrot_formdesigner.audio.events.PlausibilityDone.

Alias PlausibilityReport

Re-exported from parrot_formdesigner.core.llm_validation.PlausibilityReport.

Alias PlausibilityResult

Re-exported from parrot_formdesigner.audio.events.PlausibilityResult.

Alias Pong

Re-exported from parrot_formdesigner.audio.events.Pong.

Alias Question

Re-exported from parrot_formdesigner.audio.events.Question.

Alias QuestionPlanner

Re-exported from parrot_formdesigner.audio.planner.QuestionPlanner.

Alias QuestionSkipped

Re-exported from parrot_formdesigner.audio.events.QuestionSkipped.

Alias REFINABLE_TYPES

Re-exported from parrot_formdesigner.audio.normalize.REFINABLE_TYPES.

Alias RefineValue

Re-exported from parrot_formdesigner.audio.events.RefineValue.

Alias RepeatQuestion

Re-exported from parrot_formdesigner.audio.events.RepeatQuestion.

Alias Replan

Re-exported from parrot_formdesigner.audio.events.Replan.

Alias ReviewConfirm

Re-exported from parrot_formdesigner.audio.events.ReviewConfirm.

Alias ReviewEdit

Re-exported from parrot_formdesigner.audio.events.ReviewEdit.

Alias ReviewItem

Re-exported from parrot_formdesigner.audio.events.ReviewItem.

Alias ReviewItemData

Re-exported from parrot_formdesigner.audio.models.ReviewItemData.

Alias ReviewPrompt

Re-exported from parrot_formdesigner.audio.events.ReviewPrompt.

Alias ReviewStart

Re-exported from parrot_formdesigner.audio.events.ReviewStart.

Alias RunPlausibility

Re-exported from parrot_formdesigner.audio.events.RunPlausibility.

Alias SaveSnapshot

Re-exported from parrot_formdesigner.audio.events.SaveSnapshot.

Alias SectionEnter

Re-exported from parrot_formdesigner.audio.events.SectionEnter.

Alias SessionEnded

Re-exported from parrot_formdesigner.audio.events.SessionEnded.

Alias SessionResumed

Re-exported from parrot_formdesigner.audio.events.SessionResumed.

Alias SessionStarted

Re-exported from parrot_formdesigner.audio.events.SessionStarted.

Alias SkipQuestion

Re-exported from parrot_formdesigner.audio.events.SkipQuestion.

Alias StartSession

Re-exported from parrot_formdesigner.audio.events.StartSession.

Alias StoreBlob

Re-exported from parrot_formdesigner.audio.events.StoreBlob.

Alias Submit

Re-exported from parrot_formdesigner.audio.events.Submit.

Alias SubmitDone

Re-exported from parrot_formdesigner.audio.events.SubmitDone.

Alias Synthesize

Re-exported from parrot_formdesigner.audio.events.Synthesize.

Alias Transcribe

Re-exported from parrot_formdesigner.audio.events.Transcribe.

Alias TranscriptReady

Re-exported from parrot_formdesigner.audio.events.TranscriptReady.

Alias Transcription

Re-exported from parrot_formdesigner.audio.events.Transcription.

Alias ValidationErrors

Re-exported from parrot_formdesigner.audio.events.ValidationErrors.

Alias ValueRefined

Re-exported from parrot_formdesigner.audio.events.ValueRefined.

Alias VoiceCommand

Re-exported from parrot_formdesigner.audio.commands.VoiceCommand.

Alias VoiceFormConfig

Re-exported from parrot_formdesigner.core.voice.VoiceFormConfig.

Alias classify_command

Re-exported from parrot_formdesigner.audio.commands.classify_command.

Alias field_voice_meta

Re-exported from parrot_formdesigner.core.voice.field_voice_meta.

Alias is_sensitive

Re-exported from parrot_formdesigner.core.voice.is_sensitive.

Alias llm_validation_enabled

Re-exported from parrot_formdesigner.core.llm_validation.llm_validation_enabled.

Alias match_option

Re-exported from parrot_formdesigner.audio.option_matcher.match_option.

Alias match_review_item

Re-exported from parrot_formdesigner.audio.option_matcher.match_review_item.

Alias normalize

Re-exported from parrot_formdesigner.audio.narration.lexicon.normalize.

Alias normalize_spoken

Re-exported from parrot_formdesigner.audio.normalize.normalize_spoken.

Alias validate_typed

Re-exported from parrot_formdesigner.audio.normalize.validate_typed.

Alias wrap_voice

Re-exported from parrot_formdesigner.core.voice_answer.wrap_voice.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally