-- Live enrolled-voice observations. Every live chunk (record page AND bot
-- meetings) gets a voiceprint match against enrolled speakers; the verdict is
-- recorded here per chunk regardless of whether the UI shows it. In-person
-- recordings label lines live from this; bot meetings keep the platform's
-- active-speaker label visibly, but the system still KNOWS who the voiceprint
-- says was talking (cross-checks, alias learning, attendee confirmation).
-- Strong matches (score >= 0.55, bench-validated) also upsert a
-- source='voice' attendee row.
-- Live PG < 9.5: plain CREATE INDEX. Also folded into 2026_07_13_meetings_combined.sql.

CREATE TABLE IF NOT EXISTS meeting_voice_obs (
    id            varchar(32) NOT NULL PRIMARY KEY,
    meeting_id    varchar(32) NOT NULL,
    company       varchar(32) NOT NULL,
    source        varchar(8)  NOT NULL,            -- bot | live
    offset_ms     integer     NOT NULL DEFAULT 0,
    dur_ms        integer     NOT NULL DEFAULT 0,
    platform_name varchar(128),                    -- bot active-speaker label ('' on record path)
    voice_name    varchar(128),                    -- best enrolled match
    voice_user_id varchar(32),
    score         numeric(4,3),
    created       timestamp   NOT NULL DEFAULT now()
);

CREATE INDEX idx_mvo_meeting ON meeting_voice_obs (meeting_id);
