Skip to content

Guard plot_stimuli against missing audio / word events#47

Open
sepehrheravi wants to merge 1 commit intofacebookresearch:mainfrom
sepehrheravi:fix/plot-stimuli-silent-video
Open

Guard plot_stimuli against missing audio / word events#47
sepehrheravi wants to merge 1 commit intofacebookresearch:mainfrom
sepehrheravi:fix/plot-stimuli-silent-video

Conversation

@sepehrheravi
Copy link
Copy Markdown

Summary

plot_stimuli assumed every segment has audio and word events. Silent clips
and screen recordings have neither. main.py already auto-drops missing
extractors — this PR adds matching None-guards on the plotting side.

Changes

`tribev2/plotting/base.py`:

  • Plot audio only when `get_audio(...)` is non-None.
  • Guard `SOUND_KEY` axis lookup.
  • Skip word-overlay loop when `segment.events` is None or lacks `type` column.

Test plan

  • Sintel clip (speech + audio): renders identically to before.
  • Silent screen recording: previously raised `AttributeError`,
    now renders with blank audio/text panels and video frames.

Fixes #46

BasePlotBrain.plot_stimuli crashed for silent or speechless clips because
it unconditionally called audio.to_soundarray() and events.type. This made
plot_timesteps(show_stimuli=True) unusable for screen recordings and any
video where WhisperX produces zero words, even though main.py already
handles the missing-modality case by auto-dropping the text extractor.

- Plot the audio waveform only when get_audio(...) returns non-None.
- Skip the word-overlay loop when segment.events is None or has no
  'type' column.
- Behaviour is unchanged when both modalities are present.

Fixes facebookresearch#46
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plot_stimuli crashes on silent / speechless video clips

1 participant