speechbrain.inference is not working

Open
#2,632 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
huggingface, python

Research direction

Reproduce the failure in a fresh Google Colab environment using the listed clone, requirements installation, and editable install commands, then run the provided Sepformer import and example script. Inspect how the installed package exposes the speechbrain namespace; the issue is done when the documented speechbrain.inference imports and example complete without ModuleNotFoundError.

Written by the indexing model from the issue text.

Description

bug
Describe the bug

I am now trying to call the Sepformer based on this tutorial from Hugging Face. But after installing the toolkit according to the instruction, seems like it cannot be properly run.

Expected behaviour

After running the script according to the instruction, speechbrain.inference cannot be properly called with simple error

ModuleNotFoundError: No module named 'speechbrain.inference'
To Reproduce

On Colab, first run

!git clone https://github.com/speechbrain/speechbrain.git
!cd speechbrain && pip install -r requirements.txt && pip install -e .

Then run

from speechbrain.inference.separation import SepformerSeparation as separator
from speechbrain.inference.interfaces import fetch
from speechbrain.inference.metrics import SNREstimator as snrest

import torchaudio

# 1- Download a test mixture
fetch("test_mixture.wav", source="speechbrain/sepformer-wsj02mix", savedir=".", save_filename="test_mixture.wav")

# 2- Separate the mixture with a pretrained model (sepformer-whamr in this case)
model = separator.from_hparams(source="speechbrain/sepformer-whamr", savedir='pretrained_models/sepformer-whamr')
est_sources = model.separate_file(path='test_mixture.wav')

# 3- Estimate the performance
snr_est_model = snrest.from_hparams(source="speechbrain/REAL-M-sisnr-estimator",savedir='pretrained_models/REAL-M-sisnr-estimator')
mix, fs = torchaudio.load('test_mixture.wav')
snrhat = snr_est_model.estimate_batch(mix, est_sources)
print(snrhat) # Estimates are in dB / 10 (in the range 0-1, e.g., 0 --> 0dB, 1 --> 10dB)
Environment Details

Google colab default environment
Speechbrain version: 1.0.0 (installed from source)

Relevant Log Output

No response

Additional Context

No response

Dominant language
Python
Stars
11.8k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from speechbrain/speechbrain

All issues in speechbrain/speechbrain

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.