Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use narrowband? #1447

Open
johnchienbronci opened this issue Jan 13, 2025 · 2 comments
Open

How to use narrowband? #1447

johnchienbronci opened this issue Jan 13, 2025 · 2 comments

Comments

@johnchienbronci
Copy link

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/mixed.py", line 285, in getattr) = self._assert_one_data_cut_with_attr_and_return_it_with_track_index(name)
File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/mixed.py", line 378, in
_assert_one_data_cut_with_attr_and_return_it_with_track_index assert len(non_padding_cuts_with_custom_attr) == 1, ( AssertionError: This MixedCut has 0 non-padding cuts with a custom attribute 'narrowband'. We currently don't support mixing custom attributes. Consider dropping the attribute on all but one of DataCuts. Problematic cut:

    if config.perturb_speed:
        cuts = CutSet.mux(
            cuts,
            cuts.perturb_speed(0.9),
            cuts.perturb_speed(1.1),
        )
    if config.perturb_narrow:
        cuts = CutSet.mux(
            cuts,
            cuts.narrowband(codec="lpc10", restore_orig_sr=True),
        )
@pzelasko
Copy link
Collaborator

I couldn't reproduce your issue with the following snippet:

from lhotse import *

cuts = CutSet.from_file("libri-train-5.jsonl.gz")

cuts = CutSet.mux(
    cuts,
    cuts.perturb_speed(0.9),
    cuts.perturb_speed(1.1),
)

cuts = CutSet.mux(
    cuts,
    cuts.narrowband(codec="mulaw", restore_orig_sr=True),
)

for c in cuts:
    c.load_audio()

Can you update lhotse to the latest version and try again, or share more details?

@johnchienbronci
Copy link
Author

lhotse version use 1.29.0

set cuts = CutSet.mux( cuts, cuts.narrowband(codec="mulaw", restore_orig_sr=True)) encountered no issues, but an error occurs when training starts.

Maybe nemo training issue ?

the detail msg:

Error executing job with overrides: []
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/mixed.py", line 300, in __getattr__
    ) = self._assert_one_data_cut_with_attr_and_return_it_with_track_index(name)
  File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/mixed.py", line 401, in _assert_one_data_cut_with_attr_and_return_it_with_track_index
    assert len(non_padding_cuts_with_custom_attr) == 1, (
AssertionError: This MixedCut has 0 non-padding cuts with a custom attribute 'narrowband'. We currently don't support mixing custom attributes. Consider dropping the attribute on all but one of DataCuts. Problematic cut:
  MixedCut(id='4a84eb03-8d1f-d9b7-4d2b-9deb1beb3711_sp0.9_vp0.3', tracks=[MixTrack(cut=MonoCut(id='1759edc3-72ae-2244-8b01-63c1cd9d2b7d_sp0.9_vp0.3', start=0.0, duration=30.77775, channel=0, supervisions=[SupervisionSegment(id='/corpus/20250110_0392-0002.wav-000000-002770_sp0.9_vp0.3', recording_id='/corpus/202501/20250110/20250110_0392-0002.wav_sp0.9_vp0.3', start=0.0, duration=30.77775, channel=0, text='xxxxx', language=None, speaker=None, gender=None, custom={'tokens': array([ 996,    0,  996,    0,  996,    0,  996,    0,  996,    0,  996, 0,  996,    0,  996,    0,  765, 1009, 1008,  541,  689,  996, 0])}, alignment=None)], features=None, recording=Recording(id='/corpus/20250110_0392-0002.wav_sp0.9_vp0.3', sources=[AudioSource(type ='file', channels=[0], source='/corpus/20250110_0392-0002.wav')], sampling_rate=16000, num_samples=492444, duration=30.77775, channel_ids=[0], transforms=[Speed(factor=0.9), Volume(factor=0.3)]), custom={'text': 'xxxxx'}), type='MonoCut', offset=0.0, snr=None), MixTrack(cut =MonoCut(id='e005b860-51ef-1922-fe43-c49e149818d1_sp0.9_vp0.3', start=0.0, duration=3.4539375, channel=0, supervisions=[SupervisionSegment(id='noise-free-sound-0630_sp0.9_vp0.3', recording_id='noise-free-sound-0630_sp0.9_vp0.3', start=0.0, duration=3.4539375, channel=0, text='', language=None, speaker=None, gender=None, custom=None, alignment=None)], features=None, recording=Re cording(id='noise-free-sound-0630_sp0.9_vp0.3', sources=[AudioSource(type='file', channels=[0], source='/corpus/noise/free-sound/noise-free-sound-0630.wav')], sampling_rate=16000, num_samples=55263, duration=3.4539375, channel_ids=[0], transforms=[Speed(factor=0.9), Volume(factor=0.3)]), custom={'text': ''}), type='MonoCut', offset=0.0, snr=12.423998112834207), MixTrack(cut=MonoCut(id='7d41e602-eece-328b-ff7b-118e820865d6_sp0.9_vp0.3', start=35.5460625, duration=27.26825, channel=0, supervisions=[SupervisionSegment(id='music-fma-wa-0059_sp0.9_vp0.3', recording_id='music-fma-wa-0059_sp0.9_vp0.3', start=-35.5460625, duration=169.7088125, channel=0, text='', language=None, speaker=None, gender=None, custom=None, alignment=None)], features=None, recording=Recording(id='music-fma-wa-0059_sp0.9_vp0.3', sources=[AudioSource(type='file', channels=[0], source='/corpus/music/fma-western-art/music-fma-wa-0059.wav')], sampling_rate=16000, num_samples=2715341, duration=169.7088125, channel_ids=[0], transforms=[Speed(factor=0.9), Volume(factor=0.3)]), custom={'text': ''}), type='MonoCut', offset=3.4539375, snr=12.423998112834207)], transforms=None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/trainer/call.py", line 43, in _call_and_handle_interrupt
    return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/strategies/launchers/subprocess_script.py", line 105, in launch
    return function(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/trainer/trainer.py", line 579, in _fit_impl
    self._run(model, ckpt_path=ckpt_path)
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/trainer/trainer.py", line 986, in _run
    results = self._run_stage()
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/trainer/trainer.py", line 1030, in _run_stage
    self.fit_loop.run()
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/loops/fit_loop.py", line 197, in run
    self.setup_data()
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/loops/fit_loop.py", line 263, in setup_data
    iter(self._data_fetcher)  # creates the iterator inside the fetcher
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/loops/fetchers.py", line 104, in __iter__
    super().__iter__()
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/loops/fetchers.py", line 51, in __iter__
    self.iterator = iter(self.combined_loader)
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/combined_loader.py", line 351, in __iter__
    iter(iterator)
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/combined_loader.py", line 92, in __iter__
    super().__iter__()
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/combined_loader.py", line 43, in __iter__
    self.iterators = [iter(iterable) for iterable in self.iterables]
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/combined_loader.py", line 43, in <listcomp>
    self.iterators = [iter(iterable) for iterable in self.iterables]
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 484, in __iter__
    return self._get_iterator()
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 415, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 1191, in __init__
    self._reset(loader, first_iter=True)
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 1228, in _reset
    self._try_put_index()
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 1471, in _try_put_index
    index = self._next_index()
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 691, in _next_index
    return next(self._sampler_iter)  # may raise StopIteration
  File "/usr/local/lib/python3.10/dist-packages/lhotse/dataset/sampling/base.py", line 299, in __next__
    batch = self._next_batch()
  File "/usr/local/lib/python3.10/dist-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 299, in _next_batch
    batch = next(self.cuts_iter)
  File "/usr/local/lib/python3.10/dist-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 588, in __iter__
    self._collect_cuts_in_buckets(self.buffer_size)
  File "/usr/local/lib/python3.10/dist-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 768, in _collect_cuts_in_buckets
    cuts = next(self.cuts_iter)
  File "/usr/local/lib/python3.10/dist-packages/lhotse/dataset/sampling/dynamic.py", line 377, in __iter__
    for item in self.iterator:
  File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/set.py", line 2710, in __iter__
    yield from self.cuts
  File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/set.py", line 2710, in __iter__
    yield from self.cuts
  File "/usr/local/lib/python3.10/dist-packages/lhotse/lazy.py", line 443, in __iter__
    item = next(selected)
  File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/set.py", line 2710, in __iter__
    yield from self.cuts
  File "/usr/local/lib/python3.10/dist-packages/lhotse/lazy.py", line 695, in __iter__
    ans = self.fn(item)
  File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/set.py", line 1609, in <lambda>
    lambda cut: cut.narrowband(
  File "/usr/local/lib/python3.10/dist-packages/lhotse/cut/mixed.py", line 303, in __getattr__
    raise AttributeError(
AttributeError: No such attribute: 'narrowband' (note: custom attributes are not supported when a MixedCut consists of more than one MonoCut with that attribute).

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

No branches or pull requests

2 participants