Skip to content

Speech plans

app.encounter.speech_plan

Per-turn speech plans: how long the patient waits, how disfluent, what shape and how certain.

Real patients answer after short gaps, slow down for recall, wait longer before denials, sensitive disclosures and "I don't know", hedge more often than they sound sure, and are disfluent in bursts (many turns stay clean). See docs/research/patient-speech.md. Plans are deterministic per encounter and turn, recorded on the event, and never change facts: the guard checks the realized wording keeps every number, duration and negation.

LATENCY_MS = {'simple': (150, 400), 'ordinary': (300, 800), 'recall': (800, 1500), 'dispreferred': (700, 2000)} module-attribute

BUDGET_WEIGHTS = ((0, 0.45), (1, 0.3), (2, 0.17), (3, 0.08)) module-attribute

SHAPES = ('minimal', 'minimal_expansion', 'narrative', 'off_target', 'trailing', 'dont_know') module-attribute

MARKERS = ('matlab', 'woh', 'kya bolte hain', 'toh', 'haan', 'achha', 'bas', 'thoda', 'hai na', 'jaise') module-attribute

HONORIFICS = ('doctor sahab', 'sir') module-attribute

SENSITIVE_FACTS = {'tobacco', 'smoking', 'alcohol', 'background', 'fears', 'concern', 'belief', 'wishes', 'meds', 'medication', 'medications', 'other_drugs'} module-attribute

NUMBER_WORDS = {'एक': 1, 'दो': 2, 'तीन': 3, 'चार': 4, 'पाँच': 5, 'पांच': 5, 'छह': 6, 'छः': 6, 'सात': 7, 'आठ': 8, 'नौ': 9, 'दस': 10, 'ग्यारह': 11, 'बारह': 12, 'तेरह': 13, 'पंद्रह': 15, 'बीस': 20, 'पच्चीस': 25, 'तीस': 30, 'चालीस': 40, 'पचास': 50, 'सौ': 100, 'teen': 3, 'chaar': 4, 'paanch': 5, 'chhe': 6, 'aath': 8, 'barah': 12, 'bees': 20, 'sau': 100} module-attribute

NEGATIONS = {'नहीं', 'नही', 'ना', 'न', 'मत', 'कोनी', 'no', 'not', 'never', 'nahi', 'nahin', 'mat', 'koni'} module-attribute

WORD = re.compile('[\\wऀ-\u0dff]+') module-attribute

DIGITS = re.compile('\\d+(?:[.,]\\d+)?') module-attribute

SAFETY = 'If you correct a number, end on the permitted value. Never put a filler next to a negation, never add or change facts.' module-attribute

FILLER_TOKENS = {'matlab', 'woh', 'वो', 'मतलब', 'achha', 'अच्छा', 'अं', 'umm', 'uh', 'kya bolte hain'} module-attribute

HEDGES = ('shayad', 'शायद', 'लगता है', 'lagta hai', 'pata nahi', 'पता नहीं', 'थोड़ा सा', 'thoda sa', 'kabhi kabhi', 'कभी-कभी') module-attribute

latency_class(content, fact_id=None, answer_class=None)

plan(case, state, encounter, sequence, content, fact_id=None, answer_class=None, affect=None, condition=None)

The speech plan for one patient turn. Neutral audio and text conditions keep timing but drop disfluency.

instruction(p)

Realizer guidance for this turn; it shapes wording only, never facts.

guard(text, permitted)

Reasons the realized wording is unsafe; empty when every number, duration and negation survives.

segments(text, max_segments=3)

Clause segments for segmented synthesis, split at pauses and clause punctuation.

text_statistics(replies)

Disfluency and length statistics from reply text alone, for baselines without plans.

statistics(events)

Session speech statistics against the research targets.