Skip to content

API Reference parrot_formdesigner.core.voice_answer

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

parrot_formdesigner.core.voice_answer

View source

Canonical value shape for voice-note answers (FEAT-488).

A TEXT_AREA field with accept_content_types containing "application/json" may receive a VoiceAnswerEnvelope dict as its submission value. The validator passes it through unchanged; the consumer is responsible for parsing.

Alias AudioAnswer

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

Alias PlausibilityVerdict

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

Class VoiceAnswerEnvelope

Dual payload for a voice-note answer on a text field.

Fields:

Field Type Default Description
answer str Transcription / text answer (required).
blob_ref str | None None Server-side voice note storage reference. Pre-populated by the audio renderer before submission. None when no blob has been stored (text-only fallback).
data_url str | None None Inline base64 audio data URL for small notes. None when the audio is stored server-side via blob_ref.

Class VoiceEvidenceEnvelope

Envelope for any spoken answer (FEAT-649): typed answer + STT/recording evidence.

answer carries the field's normalised scalar (list for MULTI_SELECT, bool for BOOLEAN, ...). The FEAT-488 base keeps answer: str.

Attributes:

Attribute Type Description
answer Any
confidence float | None
source Literal['speech']
audio_mime str | None
duration_ms int | None
language str | None
plausibility PlausibilityVerdict | None
normalized_by Literal['rules', 'llm'] | None
llm_confidence float | None

Function is_voice_envelope

True for a voice envelope: a model instance, a speech evidence dict, or the exact v1 dict shape.

Upload/photo answers ({answer, blob_ref, display} or {answer, filename, content_type, blob_ref, …}) are NOT voice: any key outside answer / blob_ref / data_url rules the v1 shape out.

is_voice_envelope(value: Any) -> bool

Parameter Type Default Description
value Any

Returns: bool

Function unwrap_voice

Return a new dict where every envelope is replaced by its answer.

unwrap_voice(data: dict[str, Any]) -> dict[str, Any]

Parameter Type Default Description
data dict[str, Any]

Returns: dict[str, Any]

Function wrap_voice

Re-fold sanitised scalars into envelopes for spoken answers.

For each field_id whose evidence[field_id].source == "speech" the scalar becomes VoiceEvidenceEnvelope(...).model_dump(); all other values are copied. Values that already are envelopes are kept as-is (idempotent).

wrap_voice(scalars: dict[str, Any], evidence: dict[str, AudioAnswer]) -> dict[str, Any]

Parameter Type Default Description
scalars dict[str, Any]
evidence dict[str, AudioAnswer]

Returns: dict[str, Any]

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