Lhotse AudioToAudio dataset (supports ref recording and embedding)
State: closed | Pull request: yes
Labels: name: stale

name: ASR

name: common

# What does this PR do ?

We're adding several features to enable audio-to-audio dataloading:
* Conversion script from NeMo audio-to-audio manifests to Lhotse format 
* Audio-to-audio Lhotse dataset (covers a2a, a2a with reference and a2a with embedding cases)
* Auto-supports Lhotse Shar (tarred) format for audio-to-audio
* Options to cut/truncate examples into smaller chunks on the fly

**Collection**: All speech collections

# Changelog 
* Conversion script from NeMo audio-to-audio manifests to Lhotse format 
* Audio-to-audio Lhotse dataset (covers a2a, a2a with reference and a2a with embedding cases)
* Auto-supports Lhotse Shar (tarred) format for audio-to-audio
* Options to cut/truncate examples into smaller chunks on the fly

# Usage

Generally the workflow to use this is as follows:

```bash
# First convert NeMo manifest to Lhotse:
python scripts/audio_to_audio/convert_nemo_to_lhotse.py \
  nemo_manifest.json \
  lhotse_manifest.jsonl.gz \
  -i input_filepath \
  -t target_filepath

# Then, convert to Lhotse Shar (tarred) format
# Meaning of args: 
#  -j4 is 4 jobs
# -s 100 is the shard size
# -c specifies custom fields we want to export and their format, see lhotse shar export --help
lhotse shar export \
  -j4 -v -s 100 \
  -a flac \
  -c target_recording:flac \
  lhotse.jsonl.gz \
  data_shar
```

Then you can instantiate the dataloader like the following:

```python
from omegaconf import OmegaConf
from nemo.collections.common.data.lhotse import get_lhotse_dataloader_from_config
from nemo.collections.asr.data.audio_to_audio_lhotse import LhotseAudioToTargetDataset

config = {
   'shar_path': 'data_shar',
   'sample_rate': 16000,
   'batch_duration': 100,
   'use_bucketing': True,
   'num_buckets': 2,
}

dl = get_lhotse_dataloader_from_config(
   OmegaConf.create(config), global_rank=0, world_size=1, dataset=LhotseAudioToTargetDataset()
)
```

# Jenkins CI
To run Jenkins, a NeMo User with write access must comment `jenkins` on the PR.

# Before your PR is "Ready for review"
**Pre checks**:
- [x] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [x] Did you write any new necessary tests?
- [ ] Did you add or update any necessary documentation?
- [ ] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  - [ ] Reviewer: Does the PR have correct import guards for all optional libraries?
  
**PR Type**:
- [x] New Feature
- [ ] Bugfix
- [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.


## Who can review?

Anyone in the community is free to review the PR once the checks have passed. 
[Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
* Related to # (issue)


~Note: requires some fixes in lhotse, will bump the requirements as soon as I release it.~ EDIT: done

jenkins

jenkins

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

This PR was closed because it has been inactive for 7 days since being marked as stale.

jenkins

jenkins

jenkins

jenkins

jenkins

jenkins

jenkins

Everything passed in jenkins, merging