Velma Streaming
Real-time conversation analysis over WebSocket — stream audio and receive clips, conversation type, participant roles, behaviors, topics, sentiment, a summary, conversation dynamics, assessments, and a deepfake summary as they are produced.
done event.
Endpoint
wss://platform.modulate.ai/api/velma-2-streaming
Authentication
Pass your API key as a query parameter when opening the connection.wss://platform.modulate.ai/api/velma-2-streaming?api_key=YOUR_API_KEY
X-API-Key header. The key must be in the query string at connection time.Connection parameters
Connection parameters carry only the API key and audio-format hints. All analysis configuration is sent in the config frame, not the query string.| Parameter | Type | Required | Description |
|---|---|---|---|
api_key | string | Yes | Your API key |
audio_format | string | Raw formats only | Audio encoding. Omit for self-describing formats; required for raw/headerless formats. May optionally be set to override auto-detection |
sample_rate | integer | Raw formats only | Sample rate in Hz. Required for raw formats; must not be set otherwise |
num_channels | integer | Raw formats only | Number of channels (1–8). Required for raw formats; must not be set otherwise |
Supported audio formats
Self-describing formats (auto-detected from file headers — no extra parameters needed): AAC, AIFF, FLAC, MP3, OGG, WAV, WebMaudio_format=ogg, not audio_format=opus.audio_format, sample_rate, and num_channels):
s8, s16le, s16be, s24le, s24be, s32le, s32be, u8, u16le, u16be, u24le, u24be, u32le, u32be, f32le, f32be, f64le, f64be, mulaw, alaw
Valid sample rates: 8000, 11025, 16000, 22050, 32000, 44100, 48000, 96000
Configuration
After the connection opens, send exactly one text frame before any audio:- The literal string
defaultto use the built-in default configuration, or - A JSON-encoded
BatchConfigdescribing the conversation types, participant roles, behaviors, STT options, and which aggregate outputs (topics, sentiments, summary) to produce.
BatchConfig schema is shared with the batch endpoint — see the Batch reference for the full field list. Behaviors may be referenced from the preset catalog with the preset:<identifier> syntax; list available presets with List behavior presets.
{
"behaviors": ["preset:conflict_de_escalation", "preset:complaints"],
"stt": { "speaker_diarization": true, "emotion_signal": true, "audio_quality_signal": true },
"produce_topics": true,
"produce_topic_sentiments": true,
"produce_summary": true,
"conversation_dynamics": true,
"assessments": { "requests": true, "corrections": true, "interruption_recovery": false },
"produce_deepfake_summary": true,
"deepfake_summary_interval_seconds": 30
}
1003.Streaming-specific keys
These keys select the events that are only emitted on request. All of them are shared with batch, which returns the same data as response fields instead of events.| Key | Default | Effect |
|---|---|---|
stt.audio_quality_signal | false | Measures every finalized clip’s own audio and delivers the result as audio_quality on that clip’s clip_update event. The clip event itself carries null. Analyzed audio is capped per stream; clips past the cap carry null. |
conversation_dynamics | false | Emits a conversation_dynamics event after each finalized clip and once more before done, plus an interruption, false_start, or repeat event the first time each located event is found. |
assessments | all false | Object with requests, corrections, and interruption_recovery flags. Each enabled signal emits assessment events as its judgments complete and is covered in one assessments event before done. With every flag off, or the object omitted, neither event is emitted. |
produce_deepfake_summary | false | Emits deepfake_summary events: per-speaker clip counts and talk time by context verdict, plus an overall assessment per speaker. |
deepfake_summary_interval_seconds | 0 | 0 emits a single deepfake_summary immediately before done. 5 to 300 also emits one on that interval of wall clock from connection start, even with no change. Any other value, or a non-zero value while produce_deepfake_summary is false, is rejected as invalid configuration and closes the connection with code 1003. Batch accepts the same key but always returns only the final summary, regardless of its value. |
Connection flow
- Connect to the WebSocket endpoint with
api_key(andaudio_format,sample_rate,num_channelsfor raw formats). - Send one text frame: either the literal string
defaultor a JSON-encodedBatchConfig. - Stream audio as binary WebSocket frames. Frames can be any size.
- Receive analysis events as JSON text frames as results are produced.
- Send an empty text frame (
"") to signal end of audio. - Receive a final
doneevent with the total audio duration. - The connection closes automatically.
Server events
The server emits JSON text frames as results are produced. Every event carries atype discriminator. The payload objects (clip, conversation-type pick, participant-role pick, behavior detection, topic sentiment, speaker entries, conversation dynamics, assessments) use the same schemas the batch endpoint returns — see the Batch reference for full field definitions. The partial_clip, clip_update, and deepfake_summary payloads are streaming-only and documented below.
type | Payload key | Description |
|---|---|---|
clip | clip | A transcribed clip with speaker label, timing, and optional emotion / accent / deepfake signals |
partial_clip | partial_clip | An in-progress clip streamed while an utterance is still being spoken, before it finalizes |
clip_update | clip_update | Refined values for a previously finalized clip |
conversation_type | pick | The inferred or default conversation-type classification for the session |
participant_role | pick | The inferred or default role for a speaker |
behavior_detection | detection | A per-behavior detection result |
topics | topics | The aggregated list of conversation topics; each event fully replaces the previous one |
topic_sentiment | topic_sentiment | Per-speaker sentiment for one aggregated topic; a later event supersedes an earlier one for the same topic and speaker |
summary | text | A free-form summary of the conversation; each event fully replaces the previous one |
conversation_dynamics | speakers, conversation_dynamics | Per-speaker turn-taking entries and the conversation-level block over the transcript so far; each event fully replaces the previous one. Requires conversation_dynamics |
interruption | interruption | One located interruption, emitted once when first found. Requires conversation_dynamics |
false_start | false_start | One located false start, emitted once when first found. Requires conversation_dynamics |
repeat | repeat | One located repeated turn, emitted once when first found. Requires conversation_dynamics |
assessment | signal, event | One judged outcome for one clip of the requesting speaker, for one enabled assessment signal. Requires a flag in assessments |
assessments | assessments | Coverage of every enabled assessment over the whole stream, emitted once before done. Requires a flag in assessments |
deepfake_summary | deepfake_summary | Per-speaker deepfake assessment summary for the conversation so far. Requires produce_deepfake_summary |
done | duration_ms, model_version | Streaming completed; carries the total audio duration and the model version that produced the analysis |
error | error | An error occurred; the connection closes after this event |
conversation_dynamics event, the assessments event, and the final deepfake_summary event all precede done.
clip
A transcribed clip. Emitted progressively as speech is processed.
{
"type": "clip",
"clip": {
"clip_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"text": "Thanks for calling support, how can I help?",
"start_ms": 0,
"duration_ms": 3200,
"speaker_label": "speaker_1",
"language": "en",
"emotion": null,
"accent": null,
"deepfake_score": null,
"deepfake": null,
"audio_quality": null
}
}
emotion, accent, and deepfake_score fields are null unless the corresponding STT options are enabled in the config frame. audio_quality is always null on the clip event; when stt.audio_quality_signal is on, the measurement of the clip’s own audio arrives on its clip_update event.
On a finalized clip, deepfake_score is the latest in-progress estimate, from 0 to 1, that the voice is synthetic. It is null when the clip is too short to score or the stream has no reading yet.
deepfake_score is not necessarily its own. Until the clip has a reading, the field repeats the most recent reading from earlier in the stream, which can belong to a different speaker. The score for the whole clip arrives in a later clip_update. Act on that one.deepfake carries the standalone and context deepfake readings, computed once from a reading of this clip’s own audio. It is null whenever the clip never had a reading of its own, even when deepfake_score shows a carried-forward value from elsewhere in the stream. It is not recomputed when a later clip_update refines deepfake_score.
{
"deepfake_score": 0.07,
"deepfake": {
"standalone": { "verdict": "non-synthetic", "confidence": 0.91 },
"context": { "verdict": "non-synthetic", "confidence": 0.95, "changed": false }
}
}
standalone is read from this clip’s deepfake_score alone, with no context from other clips. context is informed by this speaker’s earlier clips: recency and clip duration weight the context, older clips decay, and strong contrary evidence flips the verdict within one clip. context is the value to display and act on. changed is true when the context verdict differs from this speaker’s previous scored clip. Readings are built separately per speaker_label; one speaker never affects another. verdict is synthetic or non-synthetic, and confidence ranges from 0 to 1.
partial_clip
An in-progress clip streamed while an utterance is still being spoken, before it finalizes. Multiple partials may be emitted for the same clip_uuid as the utterance grows; the eventual clip event for that utterance reuses the same clip_uuid, so a run of partials can be correlated with its final clip.
{
"type": "partial_clip",
"partial_clip": {
"clip_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"text": "Thanks for calling support,",
"start_ms": 0,
"end_ms": 1800,
"speaker_label": "speaker_1",
"emotion": null,
"accent": null,
"deepfake_score": null
}
}
end_ms is the current end of the in-progress utterance and grows as the utterance extends; it is null until available. The finalized clip reports duration_ms instead of end_ms. speaker_label is null until diarization resolves the speaker. emotion and accent carry the latest in-progress values, or null when no value is available yet. deepfake_score carries the most recent reading in the stream until the clip has one of its own, so it is null only before the stream’s first reading.
clip_update
Refined values for a previously finalized clip; clip_update.clip_uuid matches the clip_uuid of an earlier clip event. A finalized clip may receive any number of clip_update events (including none), each emitted after that clip’s clip event — possibly interleaved with events for other clips — and always before the done event on clean completion. For each field present, the latest received value supersedes the value on the clip event and on any earlier clip_update for that clip.
{
"type": "clip_update",
"clip_update": {
"clip_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"emotion": "Calm",
"accent": "American",
"deepfake_score": 0.04
}
}
deepfake_score on a clip_update is the score for the whole clip, from 0 to 1, and supersedes the in-progress value on the clip event. It is null when no reading is available, for example when the clip is too short or contains no scorable speech.
audio_quality is the measurement of this clip’s own audio when stt.audio_quality_signal is on. It is null when the option is off, when the clip’s audio could not be measured, or when the stream’s analyzed-audio cap was already reached.
{
"type": "clip_update",
"clip_update": {
"clip_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"audio_quality": {
"snr_db": 24.6,
"level_dbfs": -18.2,
"clipped_fraction": 0,
"glitch_events": [],
"dropout_events": [{ "start_ms": 1240, "end_ms": 1310 }]
}
}
}
| Field | Type | Contents |
|---|---|---|
snr_db | number or null | Speech level over background level in dB, estimated from the loudest and quietest frames of the clip. A proxy, not a measured noise floor. Null when the clip is too short to estimate. |
level_dbfs | number or null | Overall level of the clip in dBFS. Null when nothing was analyzed. |
clipped_fraction | number | Fraction of samples at or near full scale, from 0 to 1. |
glitch_events | array | Spans that repeat audio heard lag_ms earlier: a replayed buffer or a duplicated word. Each entry has start_ms, end_ms, and lag_ms, in milliseconds from the start of the stream. |
dropout_events | array | Brief near-silent gaps inside speech. Each entry has start_ms and end_ms, in milliseconds from the start of the stream. |
conversation_type
The conversation-type classification for the session.
{
"type": "conversation_type",
"pick": {
"conversation_type_uuid": "8f1d2c3b-4a5e-6f70-8192-a3b4c5d6e7f8",
"name": "Customer support call",
"confidence": 0.92,
"selection_source": "inferred",
"detail": "Caller is seeking help resolving a billing issue.",
"reasoning": "The agent greets the caller and offers assistance with an account problem."
}
}
selection_source is one of inferred, auto_selected_single_option, or default.
participant_role
A role assignment for one speaker. Emitted once per identified speaker.
{
"type": "participant_role",
"pick": {
"speaker_label": "speaker_1",
"participant_role_uuid": "2b7c9d10-1e2f-3a4b-5c6d-7e8f90a1b2c3",
"name": "Support agent",
"confidence": 0.88,
"selection_source": "inferred",
"detail": "Speaker offers assistance and asks diagnostic questions.",
"reasoning": "Greets on behalf of the company and drives the troubleshooting."
}
}
behavior_detection
A per-behavior detection result. By default, emitted at most once per configured behavior and speaker. Set trigger_limit on the behavior to allow more than one detection per speaker. See Detecting a behavior more than once.
{
"type": "behavior_detection",
"detection": {
"behavior_uuid": "c4d5e6f7-8091-a2b3-c4d5-e6f708192a3b",
"behavior_name": "Empathy",
"speaker_label": "speaker_1",
"detected": true,
"confidence": 0.81,
"evidence_clip_uuids": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"],
"definitive_clip_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"reasoning": "Agent acknowledges the customer's frustration before resolving the issue."
}
}
topics
The aggregated list of conversation topics. May be emitted more than once as the stream progresses; each event fully replaces the previous topics event, so always treat the latest as authoritative and never merge with earlier ones.
{
"type": "topics",
"topics": ["billing", "refund policy", "account access"]
}
topic_sentiment
Per-speaker sentiment for one aggregated topic, keyed by topic and speaker. May be emitted more than once as the stream progresses; a later event supersedes an earlier one for the same topic and speaker.
{
"type": "topic_sentiment",
"topic_sentiment": {
"topic": "billing",
"speaker_label": "speaker_2",
"sentiment_score": -0.4,
"sentiment_label": "negative"
}
}
sentiment_score ranges from -1.0 (most negative) to 1.0 (most positive).
summary
A free-form summary of the conversation. May be emitted more than once as the stream progresses; each event fully replaces the previous summary event, so always treat the latest as authoritative.
{
"type": "summary",
"text": "The customer called about a duplicate charge. The agent confirmed the error, issued a refund, and explained the billing cycle."
}
conversation_dynamics
The speaker entries and the conversation-level block over the transcript so far. Emitted after each finalized clip, and once more before done with the stream’s duration known. Each event fully replaces the previous one; treat the latest as authoritative. Only emitted when conversation_dynamics is true.
Timing comes from transcript clip boundaries, not acoustic measurement. The role picks that mark a speaker as evaluated arrive over the stream, so that flag can change between events.
{
"type": "conversation_dynamics",
"speakers": [
{
"speaker_label": "speaker_1",
"role": "Support agent",
"evaluated": true,
"turn_count": 14,
"speech_ms": 21400,
"words_per_minute": 158.2,
"response_delay_ms": { "p50": 620, "p90": 1340, "max": 2100, "count": 13 },
"longest_response_delay_ms": 2100,
"stop_delay_ms": { "p50": 380, "p90": 380, "max": 380, "count": 1 },
"repeat_count": 0,
"interruptions_made": 1,
"interruptions_received": 1,
"interruption_ms": 0,
"false_start_count": 0,
"audio_quality": {
"snr_db": 25.1,
"level_dbfs": -17.8,
"clipped_fraction": 0,
"glitch_event_count": 0,
"dropout_event_count": 1,
"analyzed_ms": 21400
}
},
{
"speaker_label": "speaker_2",
"role": "Customer",
"evaluated": false,
"turn_count": 13,
"speech_ms": 19700,
"words_per_minute": 171.5,
"response_delay_ms": { "p50": 540, "p90": 1100, "max": 1650, "count": 12 },
"longest_response_delay_ms": 1650,
"stop_delay_ms": null,
"repeat_count": 0,
"interruptions_made": 1,
"interruptions_received": 1,
"interruption_ms": 380,
"false_start_count": 1,
"audio_quality": {
"snr_db": 18.4,
"level_dbfs": -22.6,
"clipped_fraction": 0.002,
"glitch_event_count": 1,
"dropout_event_count": 0,
"analyzed_ms": 19700
}
}
],
"conversation_dynamics": {
"longest_silence_ms": 3200,
"talk_over_count": 2,
"talk_over_ms": 610,
"interruptions": [
{
"speaker_label": "speaker_2",
"interrupted_speaker_label": "speaker_1",
"clip_uuid": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
"interrupted_clip_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"start_ms": 2820,
"end_ms": 6900,
"evidence": "overlap",
"yield_ms": 380,
"overlap_ms": 380
},
{
"speaker_label": "speaker_1",
"interrupted_speaker_label": "speaker_2",
"clip_uuid": "c3d4e5f6-a7b8-9012-cdef-345678901234",
"interrupted_clip_uuid": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
"start_ms": 7100,
"end_ms": 9600,
"evidence": "cue",
"yield_ms": null,
"overlap_ms": null
}
],
"false_starts": [
{
"speaker_label": "speaker_2",
"clip_uuid": "e5f6a7b8-c9d0-1234-ef01-567890123456",
"interrupted_clip_uuid": "d4e5f6a7-b8c9-0123-def0-456789012345",
"start_ms": 12400,
"end_ms": 15100,
"evidence": "restart"
}
],
"repeats": []
}
}
speakers is one diarized speaker over the transcript so far. evaluated is true on the speaker the role picks identify as the party under evaluation: the one picked for a built-in representative role (customer service representative, support specialist, salesperson), with the most speech when several are. role is the name of the speaker’s participant role pick, or null without a pick. turn_count counts runs of the speaker’s consecutive clips with no other participant speaking in between. response_delay_ms and stop_delay_ms are distributions (p50, p90, max, count) in milliseconds, or null when nothing was measurable: response delay is measured over each of the speaker’s turns that follows another speaker’s turn of at least 400 ms, and stop delay over interruptions with measured overlap only. interruptions_made, interruptions_received, and interruption_ms count the entries in conversation_dynamics.interruptions that involve the speaker. audio_quality is the rollup over all of the speaker’s analyzed audio when stt.audio_quality_signal is on, with per-clip glitch and dropout events rolled up into counts, or null when none of the speaker’s audio has been measured.
A speaker with under a tenth of the loudest speaker’s speech is listed but treated as a diarization fragment: its timing fields are null and it takes part in no interruption, so a single-speaker stream does not report turn-taking against a phantom.
In conversation_dynamics, longest_silence_ms is the longest gap with nobody speaking: between speech spans of any speaker, before the first word, and in the final event after the last word to the end of the stream. It is 0 when speech leaves no gap and null when no speech is available. talk_over_count is the number of turns that overlapped another speaker’s speech and talk_over_ms the total overlap between the speech of each pair of speakers. interruptions and false_starts are in call order. The full field definitions are rendered on the Batch reference, which returns the same speakers and conversation_dynamics shapes.
interruption
One speaker cutting in on another. Emitted the first time the interruption is found and never again; later conversation_dynamics events keep listing it in interruptions. Only emitted when conversation_dynamics is true.
{
"type": "interruption",
"interruption": {
"speaker_label": "speaker_2",
"interrupted_speaker_label": "speaker_1",
"clip_uuid": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
"interrupted_clip_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"start_ms": 2820,
"end_ms": 6900,
"evidence": "overlap",
"yield_ms": 380,
"overlap_ms": 380
}
}
clip_uuid, start_ms, end_ms) and names the clip it cut off (interrupted_clip_uuid). The interrupting clip lasts at least 300 ms. evidence is overlap when the two clips overlap in time. Otherwise it records how a turn boundary within 500 ms was read: cue for an opening interruption word, cut_off for visibly truncated preceding text, resume for the cut speaker picking up again right after a short interjection, and tight_handoff for the new speaker starting within 200 ms of the other finishing a sentence. A fast reply to a question, and a short acknowledgment on a tight hand-off alone, do not count. yield_ms (how long the interrupted speaker kept talking after the interruption began) and overlap_ms are measured for overlap events only and are null otherwise.
false_start
A speaker stopping mid-sentence and restarting within 2.5 s with nobody else speaking in between. Emitted the first time the false start is found and never again. Only emitted when conversation_dynamics is true.
{
"type": "false_start",
"false_start": {
"speaker_label": "speaker_2",
"clip_uuid": "e5f6a7b8-c9d0-1234-ef01-567890123456",
"interrupted_clip_uuid": "d4e5f6a7-b8c9-0123-def0-456789012345",
"start_ms": 12400,
"end_ms": 15100,
"evidence": "restart"
}
}
clip_uuid is the restart and interrupted_clip_uuid the truncated clip. evidence is cut_off when the fragment visibly trails off, or restart when the restart opens with the fragment’s own first words. The cause is not visible in the transcript. A clip that restarts a false start is reported only as the false start, never as a repeat.
repeat
A clip whose text closely repeats one of the same speaker’s recent clips. Emitted the first time the repeat is found and never again. Only emitted when conversation_dynamics is true.
{
"type": "repeat",
"repeat": {
"speaker_label": "speaker_2",
"clip_uuid": "b8c9d0e1-f2a3-4567-b234-89012345abcd",
"repeats_clip_uuid": "a7b8c9d0-e1f2-3456-a123-789012345abc",
"similarity": 0.94
}
}
similarity ranges from 0 to 1.
assessment
One judged outcome for one clip of the requesting speaker, for one of the enabled assessment signals. Emitted when the pass that judged it completes. Passes run periodically over the clips that have enough following context, and once more at end of stream, so an event can arrive well after its clip. Non-applicable outcomes emit no event. Only emitted when the signal is true in assessments.
{
"type": "assessment",
"signal": "requests",
"event": {
"speaker_label": "speaker_2",
"responder_speaker_label": "speaker_1",
"clip_uuid": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
"evidence_clip_uuids": ["b2c3d4e5-f6a7-8901-bcde-f23456789012", "c3d4e5f6-a7b8-9012-cdef-345678901234"],
"start_ms": 2820,
"end_ms": 9600,
"outcome": "answered",
"evidence_strength": "high"
}
}
signal is requests, corrections, or interruption_recovery. speaker_label is the speaker whose request, correction, or interruption is assessed, and responder_speaker_label the speaker expected to respond: the one the role picks mark as evaluated in the conversation_dynamics speaker entries. clip_uuid is the requesting speaker’s clip the assessment is anchored to, and evidence_clip_uuids the clips the judgment cites. start_ms and end_ms span the cited evidence and are computed from clip boundaries; they are not response latency. evidence_strength is low, medium, or high.
| Signal | Outcomes |
|---|---|
requests | unanswered, answered, uncertain |
corrections | applied, ignored, asked_to_clarify, uncertain |
interruption_recovery | addressed, resumed, restarted, ignored_interruption, uncertain |
assessments
Coverage of every enabled assessment over the whole stream. Emitted once, before done. Only emitted when at least one flag in assessments is true.
{
"type": "assessments",
"assessments": {
"requests": {
"turns_assessed": 11,
"turns_total": 12,
"events": [
{
"speaker_label": "speaker_2",
"responder_speaker_label": "speaker_1",
"clip_uuid": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
"evidence_clip_uuids": ["b2c3d4e5-f6a7-8901-bcde-f23456789012", "c3d4e5f6-a7b8-9012-cdef-345678901234"],
"start_ms": 2820,
"end_ms": 9600,
"outcome": "answered",
"evidence_strength": "high"
}
]
},
"corrections": {
"turns_assessed": 11,
"turns_total": 12,
"events": []
},
"interruption_recovery": null
}
}
null when its flag was off, or when no responding and requesting speaker could be identified. turns_total is all of the requesting speaker’s clips with positive duration in the stream, and turns_assessed how many were assessed successfully, including non-applicable assessments. Each clip is assessed at most once per signal with neighboring context. Analysis is bounded: clips that were not assessed reduce turns_assessed and are not negatives, so empty events with incomplete coverage must not be interpreted as healthy. The events lists repeat what the assessment events already delivered.
deepfake_summary
Per-speaker deepfake assessment summary for the conversation so far. Only emitted when produce_deepfake_summary is true. With deepfake_summary_interval_seconds at 0 (the default), emitted once, immediately before done. With an interval of 5 to 300, emitted on that interval of wall clock from connection start, even with no change, so it can be treated as a heartbeat, plus one final, authoritative event immediately before done regardless of timing.
{
"type": "deepfake_summary",
"deepfake_summary": {
"as_of_ms": 41100,
"speakers": [
{
"speaker_label": "speaker_1",
"assessment": { "verdict": "non-synthetic", "confidence": 0.93 },
"synthetic_clip_count": 0,
"non_synthetic_clip_count": 14,
"synthetic_duration_ms": 0,
"non_synthetic_duration_ms": 21400
},
{
"speaker_label": "speaker_2",
"assessment": { "verdict": "mixed", "confidence": 0.71 },
"synthetic_clip_count": 9,
"non_synthetic_clip_count": 3,
"synthetic_duration_ms": 14800,
"non_synthetic_duration_ms": 4900
}
]
}
}
speakers has one entry per speaker with at least one scored clip; unscored clips are not counted. as_of_ms is the end time in the audio of the latest finalized clip, scored or not, so an unscored clip advances it even though it is excluded from speakers. It is 0 before any clip finalizes. Clip counts and durations are split by each clip’s context verdict. assessment.verdict is synthetic, non-synthetic, or mixed; it is mixed once the speaker has had both context verdicts, including a single flip that later reversed. assessment.confidence is the mean of context.confidence over the speaker’s counted clips.
done
Sent after all audio has been processed, in response to the end-of-stream signal.
{
"type": "done",
"duration_ms": 45000,
"model_version": "2026-10-23"
}
error
Sent if processing fails. The connection closes after this event.
{
"type": "error",
"error": "Internal server error"
}
WebSocket close codes
| Code | Meaning |
|---|---|
1000 | Normal closure after a successful done message |
1003 | Invalid or missing query parameters (unsupported audio format, sample rate, or channel count), or a protocol or configuration error — audio sent before the configuration frame, an unexpected text frame after configuration, invalid JSON, or an invalid configuration value (missing required field, unknown preset) |
1011 | Internal server error, or processing ended before completion |
4001 | The api_key query parameter is missing or invalid |
4003 | The request is not permitted |
4004 | The API key does not have access to this model |
4029 | Insufficient credits |
4030 | Concurrent request limit reached |
4031 | Monthly usage limit reached |
error JSON message is sent before the connection closes (except on 1000).
Rate limits
- Concurrent connection limits apply per model.
- Connections that exceed limits are rejected during the WebSocket handshake with close code
4030.
Examples
The examples below send a JSONBatchConfig as the config frame. To use the built-in defaults instead, send the literal string "default" in place of the JSON.
- Python (aiohttp)
- JavaScript (Node.js)
import asyncio
import json
import aiohttp
API_KEY = "YOUR_API_KEY"
AUDIO_FILE = "conversation.ogg"
CHUNK_SIZE = 8192
# Either the string "default" or a JSON-encoded BatchConfig.
CONFIG = json.dumps({
"behaviors": ["preset:conflict_de_escalation", "preset:complaints"],
"stt": {"speaker_diarization": True, "emotion_signal": True},
"produce_topics": True,
"produce_topic_sentiments": True,
"produce_summary": True,
"conversation_dynamics": True,
"produce_deepfake_summary": True,
})
async def analyze_streaming():
url = f"wss://platform.modulate.ai/api/velma-2-streaming?api_key={API_KEY}"
async with aiohttp.ClientSession() as session:
async with session.ws_connect(url) as ws:
# 1. Send the config frame before any audio.
await ws.send_str(CONFIG)
async def send_audio():
with open(AUDIO_FILE, "rb") as f:
while chunk := f.read(CHUNK_SIZE):
await ws.send_bytes(chunk)
await asyncio.sleep(CHUNK_SIZE / 4000)
await ws.send_str("") # 2. Signal end of audio.
send_task = asyncio.create_task(send_audio())
try:
async for msg in ws:
if msg.type == aiohttp.WSMsgType.TEXT:
event = json.loads(msg.data)
etype = event["type"]
if etype == "clip":
c = event["clip"]
print(f"[{c['speaker_label']}] {c['text']}")
elif etype == "partial_clip":
pc = event["partial_clip"]
print(f"[partial {pc['clip_uuid'][:8]}] {pc['text']}")
elif etype == "clip_update":
cu = event["clip_update"]
print(f"[update {cu['clip_uuid'][:8]}] emotion={cu.get('emotion')} accent={cu.get('accent')} deepfake_score={cu.get('deepfake_score')}")
elif etype == "conversation_type":
print(f"Conversation type: {event['pick']['name']}")
elif etype == "participant_role":
p = event["pick"]
print(f"Role for {p['speaker_label']}: {p['name']}")
elif etype == "behavior_detection":
d = event["detection"]
print(f"Behavior {d['behavior_name']}: detected={d['detected']}")
elif etype == "topics":
print(f"Topics: {', '.join(event['topics'])}")
elif etype == "topic_sentiment":
ts = event["topic_sentiment"]
print(f"Sentiment ({ts['topic']}, {ts['speaker_label']}): {ts['sentiment_label']}")
elif etype == "summary":
print(f"Summary: {event['text']}")
elif etype == "conversation_dynamics":
cd = event["conversation_dynamics"]
print(f"Dynamics: talk-over {cd['talk_over_count']}, interruptions {len(cd['interruptions'])}")
elif etype == "interruption":
i = event["interruption"]
print(f"Interruption: {i['speaker_label']} cut in on {i['interrupted_speaker_label']} ({i['evidence']})")
elif etype == "deepfake_summary":
for s in event["deepfake_summary"]["speakers"]:
print(f"Deepfake {s['speaker_label']}: {s['assessment']['verdict']} ({s['assessment']['confidence']:.2f})")
elif etype == "done":
print(f"Done. Duration: {event['duration_ms']}ms")
break
elif etype == "error":
print(f"Error: {event['error']}")
break
elif msg.type in (
aiohttp.WSMsgType.ERROR,
aiohttp.WSMsgType.CLOSE,
aiohttp.WSMsgType.CLOSED,
):
break
finally:
if not send_task.done():
send_task.cancel()
asyncio.run(analyze_streaming())
const WebSocket = require("ws");
const fs = require("fs");
const API_KEY = "YOUR_API_KEY";
const AUDIO_FILE = "conversation.ogg";
const CHUNK_SIZE = 8192;
// Either the string "default" or a JSON-encoded BatchConfig.
const CONFIG = JSON.stringify({
behaviors: ["preset:conflict_de_escalation", "preset:complaints"],
stt: { speaker_diarization: true, emotion_signal: true },
produce_topics: true,
produce_topic_sentiments: true,
produce_summary: true,
conversation_dynamics: true,
produce_deepfake_summary: true,
});
const url = new URL("wss://platform.modulate.ai/api/velma-2-streaming");
url.searchParams.set("api_key", API_KEY);
const ws = new WebSocket(url.toString());
ws.on("open", () => {
// 1. Send the config frame before any audio.
ws.send(CONFIG);
// 2. Stream audio as binary frames, then signal end of audio.
const stream = fs.createReadStream(AUDIO_FILE, { highWaterMark: CHUNK_SIZE });
stream.on("data", (chunk) => ws.send(chunk));
stream.on("end", () => ws.send(""));
});
ws.on("message", (data) => {
const event = JSON.parse(data.toString());
switch (event.type) {
case "clip":
console.log(`[${event.clip.speaker_label}] ${event.clip.text}`);
break;
case "partial_clip":
console.log(`[partial ${event.partial_clip.clip_uuid.slice(0, 8)}] ${event.partial_clip.text}`);
break;
case "clip_update": {
const cu = event.clip_update;
console.log(`[update ${cu.clip_uuid.slice(0, 8)}] emotion=${cu.emotion} accent=${cu.accent} deepfake_score=${cu.deepfake_score}`);
break;
}
case "conversation_type":
console.log(`Conversation type: ${event.pick.name}`);
break;
case "participant_role":
console.log(`Role for ${event.pick.speaker_label}: ${event.pick.name}`);
break;
case "behavior_detection":
console.log(`Behavior ${event.detection.behavior_name}: detected=${event.detection.detected}`);
break;
case "topics":
console.log(`Topics: ${event.topics.join(", ")}`);
break;
case "topic_sentiment": {
const ts = event.topic_sentiment;
console.log(`Sentiment (${ts.topic}, ${ts.speaker_label}): ${ts.sentiment_label}`);
break;
}
case "summary":
console.log(`Summary: ${event.text}`);
break;
case "conversation_dynamics": {
const cd = event.conversation_dynamics;
console.log(`Dynamics: talk-over ${cd.talk_over_count}, interruptions ${cd.interruptions.length}`);
break;
}
case "interruption": {
const i = event.interruption;
console.log(`Interruption: ${i.speaker_label} cut in on ${i.interrupted_speaker_label} (${i.evidence})`);
break;
}
case "deepfake_summary":
for (const s of event.deepfake_summary.speakers) {
console.log(`Deepfake ${s.speaker_label}: ${s.assessment.verdict} (${s.assessment.confidence.toFixed(2)})`);
}
break;
case "done":
console.log(`Done. Duration: ${event.duration_ms}ms`);
ws.close();
break;
case "error":
console.error(`Error: ${event.error}`);
ws.close();
break;
}
});
ws.on("error", (err) => console.error("WebSocket error:", err.message));
websocat.Related
- Velma overview — what Velma analyzes and when to use batch vs streaming
- Velma Batch — the
BatchConfigand event payload schemas in full - List behavior presets — discover behavior preset identifiers
- Authentication and rate limits
No examples found{
"type": "<string>",
"partial_clip": {
"clip_uuid": "<string>",
"text": "<string>",
"start_ms": 123,
"end_ms": 123,
"speaker_label": "<string>",
"emotion": "<string>",
"accent": "<string>",
"deepfake_score": 123
}
}No examples found{
"type": "<string>",
"pick": {
"conversation_type_uuid": "<string>",
"name": "<string>",
"confidence": 123,
"selection_source": "<string>",
"detail": "<string>",
"reasoning": "<string>"
}
}{
"type": "<string>",
"pick": {
"speaker_label": "<string>",
"participant_role_uuid": "<string>",
"name": "<string>",
"confidence": 123,
"selection_source": "<string>",
"detail": "<string>",
"reasoning": "<string>"
}
}No examples found{
"type": "<string>",
"topics": {
"item": "<string>"
}
}{
"type": "<string>",
"topic_sentiment": {
"topic": "<string>",
"speaker_label": "<string>",
"sentiment_score": 123,
"sentiment_label": "<string>"
}
}{
"type": "<string>",
"text": "<string>"
}No examples foundNo examples found{
"type": "<string>",
"interruption": {
"speaker_label": "<string>",
"interrupted_speaker_label": "<string>",
"clip_uuid": "<string>",
"interrupted_clip_uuid": "<string>",
"start_ms": 123,
"end_ms": 123,
"evidence": "<string>",
"yield_ms": 123,
"overlap_ms": 123
}
}{
"type": "<string>",
"false_start": {
"speaker_label": "<string>",
"clip_uuid": "<string>",
"interrupted_clip_uuid": "<string>",
"start_ms": 123,
"end_ms": 123,
"evidence": "<string>"
}
}{
"type": "<string>",
"repeat": {
"speaker_label": "<string>",
"clip_uuid": "<string>",
"repeats_clip_uuid": "<string>",
"similarity": 123
}
}No examples foundNo examples found{
"type": "error",
"error": "Internal server error"
}{
"type": "done",
"duration_ms": 45000,
"model_version": "2026-10-23"
}{}{}{}A transcribed clip with metadata.
An in-progress clip streamed while an utterance is still being spoken,
before it finalizes. Multiple partials may be emitted for the same
clip_uuid as the utterance grows; the eventual clip event for that
utterance reuses the same clip_uuid, so a run of partials can be
correlated with its final clip.
Refined values for a previously finalized clip;
clip_update.clip_uuid matches the clip_uuid of an earlier clip
event. A finalized clip may receive any number of clip_update
events (including none), each emitted after that clip's clip event
(possibly interleaved with events for other clips) and always before
the done event on clean completion. For each field present, the
latest received value supersedes the value on the clip event and on
any earlier clip_update for that clip. If refinement is unavailable
for a clip, its previously available values are retained.
Inferred or default conversation-type pick for the session. May be
updated as the conversation progresses; the latest pick replaces the
previous one. When conversation_type_uuid changes, or the first type
arrives after role events, discard all previous participant-role picks.
Subsequent participant_role events establish the current assignments;
a speaker may remain unassigned if no applicable role is available.
Ending the audio does not force a final type or role reassessment;
already pending updates may still arrive before done.
Inferred or default participant-role pick for a speaker. A later event
replaces the earlier pick for the same speaker_label. Role inference
is reconsidered only after additional finalized speech from that
speaker. Following a conversation-type change, a compatible earlier
role may be carried forward in a new event without reassessment.
Positive detection for a behavior and speaker. By default
(trigger_limit unset) a behavior is detected at most once per
speaker (voice); each speaker is capped independently. Setting
trigger_limit to a higher number, or explicitly to null for no
limit, allows it to be detected more than once for that speaker - up
to that many occurrences, or for every distinct occurrence found when
unlimited. Detections may arrive after end of audio;
continue reading until done to receive completed analysis.
Emitted detections remain historical when conversation types or roles
change. Updated classifications govern subsequent checks; previous
detections are not withdrawn or re-emitted.
Detections may arrive while an utterance is still in progress, after
its partial_clip event, and before type or role picks are available.
Aggregated list of conversation topics. May be emitted more than once as
the stream progresses; each event fully replaces the previous topics
event, so always treat the latest as authoritative and never merge with
earlier ones.
Per-speaker sentiment for an aggregated topic, keyed by topic and speaker. May be emitted more than once as the stream progresses; a later event supersedes an earlier one for the same topic and speaker.
Free-form summary of the conversation. May be emitted more than once as
the stream progresses; each event fully replaces the previous summary
event, so always treat the latest as authoritative.
Per-speaker deepfake assessment summary for the conversation so far,
emitted only when produce_deepfake_summary is true. With
deepfake_summary_interval_seconds at 0 (the default), emitted once,
immediately before done. With an interval of 5 to 300, emitted on
that interval of wall clock from connection start - even with no
change, so it can be treated as a heartbeat - plus one final,
authoritative event immediately before done regardless of timing.
The speaker entries and the conversation-level block over the
transcript so far, emitted after each finalized clip and once more
before done with the stream's duration known. Each event fully
replaces the previous one; treat the latest as authoritative. Only
emitted when conversation_dynamics is on. The role picks that mark
a speaker as evaluated arrive over the stream, so that flag can
change between events.
One located interruption, emitted the first time it is found and
never again; later conversation_dynamics events keep listing it.
Only emitted when conversation_dynamics is on.
One located false start, emitted the first time it is found and
never again. Only emitted when conversation_dynamics is on.
One located repeated turn, emitted the first time it is found and
never again. Only emitted when conversation_dynamics is on.
One judged outcome for a clip of the requesting speaker, for one of
the enabled assessment signals, emitted when the pass that judged it
completes. Passes run periodically over the clips that have enough
following context and once more at end of stream, so an event can
arrive well after its clip. Non-applicable outcomes emit no event.
Only emitted when the signal is on in assessments.
Coverage of every enabled assessment over the whole stream, emitted
once before done. Its events lists repeat what the assessment
events already delivered. Only emitted when any assessment is on.
An error occurred during processing.
Streaming completed.
First text frame: either the literal string default (to use
the built-in default configuration) or a JSON-encoded
BatchConfig object. To set STT options such as custom_terms,
include an stt key in the JSON-encoded BatchConfig.
Raw audio data chunk.
Empty text frame signalling end of audio stream.
No examples found{
"type": "<string>",
"partial_clip": {
"clip_uuid": "<string>",
"text": "<string>",
"start_ms": 123,
"end_ms": 123,
"speaker_label": "<string>",
"emotion": "<string>",
"accent": "<string>",
"deepfake_score": 123
}
}No examples found{
"type": "<string>",
"pick": {
"conversation_type_uuid": "<string>",
"name": "<string>",
"confidence": 123,
"selection_source": "<string>",
"detail": "<string>",
"reasoning": "<string>"
}
}{
"type": "<string>",
"pick": {
"speaker_label": "<string>",
"participant_role_uuid": "<string>",
"name": "<string>",
"confidence": 123,
"selection_source": "<string>",
"detail": "<string>",
"reasoning": "<string>"
}
}No examples found{
"type": "<string>",
"topics": {
"item": "<string>"
}
}{
"type": "<string>",
"topic_sentiment": {
"topic": "<string>",
"speaker_label": "<string>",
"sentiment_score": 123,
"sentiment_label": "<string>"
}
}{
"type": "<string>",
"text": "<string>"
}No examples foundNo examples found{
"type": "<string>",
"interruption": {
"speaker_label": "<string>",
"interrupted_speaker_label": "<string>",
"clip_uuid": "<string>",
"interrupted_clip_uuid": "<string>",
"start_ms": 123,
"end_ms": 123,
"evidence": "<string>",
"yield_ms": 123,
"overlap_ms": 123
}
}{
"type": "<string>",
"false_start": {
"speaker_label": "<string>",
"clip_uuid": "<string>",
"interrupted_clip_uuid": "<string>",
"start_ms": 123,
"end_ms": 123,
"evidence": "<string>"
}
}{
"type": "<string>",
"repeat": {
"speaker_label": "<string>",
"clip_uuid": "<string>",
"repeats_clip_uuid": "<string>",
"similarity": 123
}
}No examples foundNo examples found{
"type": "error",
"error": "Internal server error"
}{
"type": "done",
"duration_ms": 45000,
"model_version": "2026-10-23"
}{}{}{}