Skip to content

API Reference parrot_formdesigner.audio.models

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

parrot_formdesigner.audio.models

View source

Audio form session data models for parrot-formdesigner.

Pydantic models shared by the audio renderer and WebSocket handler. These models define the data contract for an audio form session.

Added by FEAT-224 (FormDesigner Audio Renderer).

Class AudioAnswer

An answer to a single audio question.

Fields:

Field Type Default Description
field_id str The field_id this answer corresponds to.
field_uid Optional[uuid.UUID] None Immutable UUID of the FormField this answer corresponds to (FEAT-393), when known. Optional — answers may be reconstructed from wire data that carries no UID.
value Any The answer value (typed/transcribed text, or a list for MULTI_SELECT).
source Literal['text', 'speech', 'selection'] 'text' Origin of the answer — 'text' for keyboard input, 'speech' for STT-transcribed audio, 'selection' for a UI selection on a PROMPT_SELECT question (FEAT-236).
confidence Optional[float] None STT confidence score (0.0–1.0) when source='speech'.
raw_transcript Optional[str] None Raw unprocessed transcript when source='speech'.
blob_ref Optional[str] None Reference to the stored audio recording, if any.
audio_mime Optional[str] None MIME type of the recording.
audio_bytes_len Optional[int] None Size of the recording in bytes.
duration_ms Optional[int] None Recording duration in milliseconds.
matched Optional[OptionMatch] None Option match resolved from the transcript, if any.
stt_language Optional[str] None Language reported by the STT engine.
normalized_by Optional[Literal['rules', 'llm']] None Post-processor that produced value (FEAT-653): 'rules', 'llm' or None.
llm_confidence Optional[float] None Confidence reported by the LLM post-processor, when it produced value.
answered_at Optional[datetime] None When the answer was accepted.
version int 1 Answer version, incremented on every re-answer.

Class AudioFormManifest

Session manifest returned by AudioFormRenderer.render().

Describes the sequential list of questions and the WebSocket endpoint for the interactive audio session.

Fields:

Field Type Default Description
form_uid str Immutable UUID of the form (FEAT-389).
title str Human-readable form title.
total_questions int Number of questions in the audio session.
questions list[AudioQuestion] Ordered list of audio questions.
ws_endpoint str WebSocket URL template for the interactive session.
locale str 'en' Resolved locale used for this manifest.

Class AudioQuestion

A single question in the audio form session.

Fields:

Field Type Default Description
index int Zero-based position in the sequential question list.
field_id str The FormField.field_id this question maps to.
field_uid uuid.UUID Immutable UUID of the FormField this question maps to (FEAT-393). WS wire messages still key on field_id by design (spec §8) — this is additive session-manifest identity only.
field_type str The FieldType value string (e.g. 'text', 'select').
label str Resolved question text shown/spoken to the user.
description Optional[str] None Optional extended description or help text.
required bool False Whether an answer is mandatory.
audio_prompt Optional[bytes] None Pre-synthesized TTS audio bytes, or None if not yet synthesized.
constraints Optional[dict] None Optional validation constraints dict.
options Optional[list[dict]] None Option list for SELECT/MULTI_SELECT fields, each entry has at least 'value' and 'label' keys.
voice_mode VoiceMode VoiceMode.VOICE The VoiceMode taxonomy classification for this question (FEAT-236).
render_mode Literal['voice', 'select', 'visual'] 'voice' Client-facing render hint derived from voice_mode — "voice" (speak + answer), "select" (UI selection), or "visual" (single-field visual fallback).
sensitive bool False When True, the client must mute TTS read-back of the value (e.g. password fields).
fallback_html Optional[str] None Pre-rendered single-field HTML for VISUAL_FALLBACK questions, or None.
accept_content_types Optional[list[str]] None List of acceptable MIME types for this field's answer. When it contains "application/json" the client may submit a dict instead of a plain string (FEAT-488).
answer_envelope Optional[Literal['voice']] None When "voice", the dict the client submits must be a VoiceAnswerEnvelope ({answer, blob_ref?, data_url?}) — the server validates that shape and rejects anything else. None means a submitted dict is treated as arbitrary JSON (FEAT-488).
section_uid Optional[str] None
section_title Optional[str] None
subsection_title Optional[str] None
hint Optional[str] None
prompt Optional[str] None
narration Optional[NarrationPlan] None
ui_cue Optional[UiCue] None
answer_modes list[str]
voice_meta Optional[FieldVoiceMeta] None
llm_validation bool False

Class AudioSessionConfig

Configuration for an audio form session.

Fields:

Field Type Default Description
form_uid str Immutable UUID of the form to render in audio mode (FEAT-389 — identity is form_uid-only; the mutable form_id slug is never used here).
locale str 'en' BCP 47 language tag for TTS and label resolution.
tts_backend Literal['supertonic', 'google'] 'supertonic' Preferred TTS backend. Defaults to "supertonic" (a sub-second ONNX backend) with a graceful fallback to "google" at synthesis time (FEAT-236).
tts_voice Optional[str] None Optional voice name to pass to the TTS backend.
tts_mime_format str 'audio/wav' MIME type of the TTS audio output. Defaults to "audio/wav" since the SuperTonic backend emits WAV.
auto_advance bool True When True, advance to the next question immediately after a valid answer without waiting for explicit confirmation.
enumerate_options bool True When True, read the option labels aloud for PROMPT_SELECT questions (e.g. "Choose one: red, green, blue").
stt_confirm_threshold float 0.6 STT confidence below which a speech answer triggers a read-back confirmation turn before being stored.

Class AudioSessionState

Server-side state for an active audio form session.

One instance is created per WebSocket connection. Not persisted by default; use Redis if resumable sessions are needed (spec open question).

Fields:

Field Type Default Description
session_id str Unique identifier for this session.
form_uid str Immutable UUID of the form being filled in this session (FEAT-389).
user_id str Authenticated user ID from JWT.
current_index int 0 Zero-based index of the current question.
answers dict[str, AudioAnswer] Map of field_id → AudioAnswer for completed questions.
manifest Optional[AudioFormManifest] None The session manifest (set after start_session).
completed bool False True when all required questions have been answered and the form has been submitted.
config Optional[AudioSessionConfig] None The resolved AudioSessionConfig for this session (FEAT-236), set at start_session. None until the session starts.
pending Optional[AudioAnswer] None A low-confidence speech answer awaiting a confirm/repeat turn (FEAT-236). None when no answer is pending confirmation.
phase Phase Phase.IDLE Current engine phase (FEAT-649).
cursor Optional[str] None field_id of the question currently asked.
history list[str] Ordered field_ids visited (for back navigation).
plan list[str] Ordered field_ids of the visible/required plan.
return_to_review bool False True when an edit should return to the review.
review_cursor int 0 Zero-based index of the review item being read.
resolution Optional[RuleResolution] None Latest rule resolution (visible/required/computed).
tenant Optional[str] None Tenant identifier, when known.
locale str 'en' Session locale.
submission_id str Pre-generated id making the commit idempotent.
protocol_version int 1 Wire protocol version (1 = legacy).
submit_mode Literal['server', 'client'] 'server' "server" persists on review_confirm; "client" replies answers_ready.
plausibility Optional[PlausibilityReport] None Latest plausibility report, if any.
flagged dict[str, int] field_id -> answer version flagged (one flag per version).
timezone Optional[str] None Client IANA timezone (FEAT-653); set on every start/resume, never snapshotted.

Alias FieldVoiceMeta

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

Class NarrationPlan

Deterministic narration for one turn: full text + ordered audio segment keys.

Fields:

Field Type Default Description
text str
audio_keys list[str]
segments dict[str, str]

Class OptionMatch

A transcript resolved to one option (or boolean / scale value).

Fields:

Field Type Default Description
value Any
label str
method Literal['exact', 'ordinal', 'yes_no', 'numeric', 'contains', 'fuzzy', 'llm']
score float

Class Phase

Audio session engine phase (FEAT-649). Re-exported by audio/events.py.

Alias PlausibilityReport

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

Class ReviewItemData

One line of the final review (position is 1-based, as narrated).

Fields:

Field Type Default Description
position int
field_id str
label str
answer_text str
skipped bool False
flagged bool False
sensitive bool False

Alias RuleResolution

Re-exported from parrot_formdesigner.services.rule_evaluator.RuleResolution.

Alias UiCue

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

Class VoiceMode

How a question participates in the audio form flow.

Introduced by FEAT-236 (Audio Renderer Form) to replace the prior "silently drop non-voiceable fields" behavior with an explicit voice-capability taxonomy so that no required field is ever lost.

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