Prosody¶
app.encounter.prosody
¶
Per-turn emotion, pace and within-response pauses for patient speech.
Expression is authored (persona voice, baseline affect, per-fact affect) and varied deterministically per turn, so replays are reproducible. Nothing here may change clinical content: pauses and fillers are inserted only between words, never next to a negation or a number, and removing them restores the original text exactly.
AFFECTS = {'calm': ('Sound composed and articulate; natural pauses only.', 1.0, 0.5), 'worried': ('Let worry show: start a little quickly, slow down on the hard part, pause once before the key word, voice slightly tight.', 1.0, 0.75), 'tired': ('Sound tired: low energy, slower, take a breath mid-answer and let one phrase trail off.', 0.94, 0.6), 'hurried': ('Sound pressed for time: quicker, clipped phrases, barely any pause between them.', 1.07, 0.7), 'guarded': ('Sound guarded: keep it short, pause before admitting anything, flatter tone.', 0.97, 0.55), 'embarrassed': ('Sound embarrassed: softer, hesitant start, break off one phrase and restart it, voice drops at the end.', 0.95, 0.7), 'frightened': ('Sound frightened: unsteady, a catch in the voice, pause mid-sentence as if collecting yourself.', 1.03, 0.85), 'in_pain': ('Sound uncomfortable: strained, short phrases, one pause as if wincing.', 0.93, 0.65), 'short_of_breath': ('Speak in short breath groups with brief pauses for breath; do not cough unless a fact says so.', 0.9, 0.6), 'relieved': ('Sound relieved: lighter, warmer, a little faster.', 1.04, 0.65)}
module-attribute
¶
NEGATIONS = {'नहीं', 'ना', 'न', 'मत', 'not', 'no', 'never', 'nahi', 'nahin', 'कभी', 'कोनी', 'koni', 'नी'}
module-attribute
¶
CLAUSE_BREAKS = {'और', 'पर', 'लेकिन', 'तो', 'फिर', 'बस', 'कि', 'but', 'and', 'so'}
module-attribute
¶
FILLERS = ('वो…', 'मतलब…', 'हाँ…', 'अं…')
module-attribute
¶
PAUSE = '…'
module-attribute
¶
NEUTRAL = 'Speak in an even, neutral tone at a steady pace, without emotional colouring.'
module-attribute
¶
turn_prosody(voice, encounter, sequence, fact_affect=None, condition=None)
¶
Affect, pace and temperature for one patient turn, within the persona's authored range.
humanize(text, affect, encounter, sequence)
¶
Insert a few unpredictable pauses (and rarely a filler) between words for speech synthesis.
strip_humanization(text)
¶
Inverse of humanize, used to prove clinical wording is untouched.