Skip to content

PYA-1783: Add multichannel support#117

Closed
MatiasDiBernardo wants to merge 2 commits into
pyannote:developfrom
MatiasDiBernardo:feat/add-multichannel-support
Closed

PYA-1783: Add multichannel support#117
MatiasDiBernardo wants to merge 2 commits into
pyannote:developfrom
MatiasDiBernardo:feat/add-multichannel-support

Conversation

@MatiasDiBernardo

Copy link
Copy Markdown

Optional multichannel support in RTTM loading

What

The RTTM channel field (column #3) was parsed but discarded. This adds an opt-in way to keep it, so a multichannel recording (telephone, per-headset,source-separated) can expose one reference Annotation per channel.

API

  • load_rttm(path, keep_channel=True) → nested {uri: {channel: Annotation}}. Default keep_channel=False is unchanged.
  • RTTMLoader returns the annotation of file["channel"] when the ProtocolFile provides one; otherwise it merges all channels (previous behavior).

Key example

Given this RTTM (column #3 is the channel):

SPEAKER conv1 1 0.0 2.0 <NA> <NA> speaker_A <NA> <NA>
SPEAKER conv1 2 1.5 1.0 <NA> <NA> speaker_B <NA> <NA>
SPEAKER conv2 1 0.0 1.0 <NA> <NA> speaker_C <NA> <NA>

Without keep_channel (default — unchanged): all channels merge into one Annotation.

>>> load_rttm("conv.rttm")
{'conv1': <Annotation>, 'conv2': <Annotation>}
>>> load_rttm("conv.rttm")['conv1'].labels()
['speaker_A', 'speaker_B']        # channels 1 and 2 merged

With keep_channel=True — one Annotation per channel:

>>> load_rttm("conv.rttm", keep_channel=True)
{'conv1': {1: <Annotation>, 2: <Annotation>}, 'conv2': {1: <Annotation>}}
>>> load_rttm("conv.rttm", keep_channel=True)['conv1'][2].labels()
['speaker_B']                     # just channel 2

At the protocol level, the same distinction is driven by a channel key on the file:

RTTMLoader("conv.rttm")({"uri": "conv1"})               # -> merged (speaker_A + speaker_B)
RTTMLoader("conv.rttm")({"uri": "conv1", "channel": 2}) # -> speaker_B only

Tests

tests/test_loader.py (+ a multichannel fixture) covers the default/merged path, the keep_channel shape and content, RTTMLoader channel selection and its backward-compatible default, and lazy channel resolution through ProtocolFile. uv run pytest tests is green.

MatiasDiBernardo and others added 2 commits June 25, 2026 16:13
`load_rttm(..., keep_channel=True)` returns a nested
{uri: {channel: Annotation}} dict (1-based channel, field pyannote#3 of the RTTM
spec) instead of merging every channel into a single Annotation.

`RTTMLoader` now returns the annotation of `file["channel"]` when the
ProtocolFile provides one, and otherwise merges all channels as before.

Fully backward compatible: the default `keep_channel=False`, and a missing
`channel` key in RTTMLoader, reproduce the previous behavior. Adds tests
covering both the legacy and channel-aware paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hbredin

hbredin commented Jul 1, 2026

Copy link
Copy Markdown
Member

We'll discuss this offline but I believe this brings a breaking change for RTTMLoader("conv.rttm")({"uri": "conv1", "channel": 2}):

  • Before: returns annotations from all channels
  • After: only returns for channel 2

I believe the new proposed behavior makes more sense but the ins and outs need to be discussed.

@MatiasDiBernardo MatiasDiBernardo changed the title Feature: Add multichannel support PYA-1783: Add multichannel support Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants