Skip to content

Commit

Permalink
Included comments
Browse files Browse the repository at this point in the history
Signed-off-by: Ante Jukić <[email protected]>
  • Loading branch information
anteju committed Apr 29, 2024
1 parent 043bf0c commit 9ed7e9b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nemo/collections/common/data/lhotse/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def get_lhotse_dataloader_from_config(
# Apply channel selector
if config.channel_selector is not None:
logging.info('Using channel selector %s.', config.channel_selector)
cuts = cuts.map(partial(_select_channel, channel_selector=config.channel_selector), apply_fn=None)
cuts = cuts.map(partial(_select_channel, channel_selector=config.channel_selector))

# Resample as a safeguard; it's a no-op when SR is already OK
cuts = cuts.resample(config.sample_rate)
Expand Down Expand Up @@ -460,4 +460,9 @@ def _select_channel(cut, channel_selector: int | str) -> list:
f"Channel index {channel_idx} is larger than the actual number of channels {cut.num_channels}"
)

return cut.with_channels(channel_idx)
if cut.num_channels == 1:
# one channel available and channel_idx==0
return cut
else:
# with_channels only defined on MultiCut
return cut.with_channels(channel_idx)

0 comments on commit 9ed7e9b

Please sign in to comment.