Skip to content

Add whisper lid stage - #57

Open
fqian1107 wants to merge 7 commits into
nithinraok:nkoluguri/integration-testfrom
fqian1107:fqian/whisper_lid
Open

Add whisper lid stage#57
fqian1107 wants to merge 7 commits into
nithinraok:nkoluguri/integration-testfrom
fqian1107:fqian/whisper_lid

Conversation

@fqian1107

@fqian1107 fqian1107 commented Jul 31, 2026

Copy link
Copy Markdown

Description

  • Add whisper LID stage, default uses: whisper.medium.
  • When speechbrain predicts indic language tag, compare with indic Canary predicted language. Set "skip_me" if the two models don't agree.
  • When speechbrain predicts non-indic language tag, compare with whipser predicted language. Set "skip_me" if the two models don't agree.

Usage

# Add snippet demonstrating usage

Checklist

  • I am familiar with the Contributing Guide.
  • New or Existing tests cover these changes.
  • The documentation is up to date with these changes.

@fqian1107
fqian1107 force-pushed the fqian/whisper_lid branch from 9c038cc to 8db1a5a Compare July 31, 2026 06:49
Signed-off-by: Fan Qian <fqian@nvidia.com>
Signed-off-by: Fan Qian <fqian@nvidia.com>
msg = "OpenAI Whisper is required for WhisperLangIDStage. Install: pip install openai-whisper"
raise ImportError(msg) from exc

_WHISPER_MAX_SAMPLES = 30 * 16_000 # 30 s at 16 kHz

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max samples from VAD are 40 secs, please change this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whisper has a max audio length of 30s, we can only trim the audio for it to run.


for task_idx, language_probabilities in zip(chunk_indices, probabilities, strict=True):
language = max(language_probabilities, key=language_probabilities.get)
tasks[task_idx].data[self.output_key] = language

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store the LID result in LangIDResult dataclass.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

return task

# Non-Indic: cross-check with Whisper when available.
if whisper_result is not None:

@sushmitha-deva-09 sushmitha-deva-09 Aug 3, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add whisper as "tertiary" model in run_metadata_pipeline.py

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Signed-off-by: Fan Qian <fqian@nvidia.com>

whisper_grp = ap.add_argument_group("Whisper LID (tertiary)")
whisper_grp.add_argument(
"--whisper",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's run whisper by default, and mark it as secondary or teritary based on indic flag. Please remove this flag.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Signed-off-by: Fan Qian <fqian@nvidia.com>
batch_size: int = 8
max_duration_sec: float = 30.0 # Whisper's input window is 30 s; base defaults to 10 s

_model: Any = field(default=None, init=False, repr=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add support for inference using local model path as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure


def _load_model(self, device: str | torch.device) -> Any:
try:
import whisper

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add whisper package to toml and update lock.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for the shared waveform/output arguments.
"""

tag: str = "tertiary"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this tag?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to remove. Fixed now.

@nithinraok nithinraok left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nithinraok

Copy link
Copy Markdown
Owner

Please add description.

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.

3 participants