Audio with filename containing spaces generate invalid rttm files
State: closed | Pull request: no
Labels: name: bug

name: stale

**Describe the bug**

NeMo uses the file name without extension as the unique id for rttm file generation.  RTTM parsing code typically expect a name that is uri-compliant, without spaces.

The typical code  used in several places is:

```
os.path.splitext(os.path.basename(sample.audio_file))[0]
```

When the file name contains space, this generates a unique_id with a space. Since the RTTM file format relies on space-separated fields, this later causes parsing error.

**Steps/Code to reproduce bug**

For example, when using the following manifest file:

```
{
    "audio_filepath": "mono vocals.wav",
    "label": "infer",
    "text": "-",
    "num_speakers": 5,
}
```

The following code:
```
neural_diarizer = NeuralDiarizer(cfg=self.config)
neural_diarizer.diarize()
```

Results in the following exception:

```
[NeMo I 2023-12-29 15:20:38 msdd_models:938] Loading cluster label file from /data/nemo/outputs/speaker_outputs/subsegments_scale4_cluster.label
Traceback (most recent call last):
  File "/data/nemo/services/nemo/diarization.py", line 224, in <module>
    main()
  File "/data/nemo/services/nemo/diarization.py", line 155, in _diarize_neural
    neural_diarizer .diarize()
  File "/data/nemo/.venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/data/nemo/.venv/lib/python3.10/site-packages/nemo/collections/asr/models/msdd_models.py", line 1180, in diarize
    self.clustering_embedding.prepare_cluster_embs_infer()
  File "/data/nemo/.venv/lib/python3.10/site-packages/nemo/collections/asr/models/msdd_models.py", line 699, in prepare_cluster_embs_infer
    self.emb_sess_test_dict, self.emb_seq_test, self.clus_test_label_dict, _ = self.run_clustering_diarizer(
  File "/data/nemo/.venv/lib/python3.10/site-packages/nemo/collections/asr/models/msdd_models.py", line 881, in run_clustering_diarizer
    emb_sess_avg_dict, base_clus_label_dict = self.get_cluster_avg_embs(
  File "/data/nemo/.venv/lib/python3.10/site-packages/nemo/collections/asr/models/msdd_models.py", line 797, in get_cluster_avg_embs
    output_clus_label_dict, emb_dim = self.get_base_clus_label_dict(clus_labels, emb_scale_seq_dict)
  File "/data/nemo/.venv/lib/python3.10/site-packages/nemo/collections/asr/models/msdd_models.py", line 759, in get_base_clus_label_dict
    stt, end = [round(float(x), 2) for x in line.split()[1:3]]
  File "/data/nemo/.venv/lib/python3.10/site-packages/nemo/collections/asr/models/msdd_models.py", line 759, in <listcomp>
    stt, end = [round(float(x), 2) for x in line.split()[1:3]]
ValueError: could not convert string to float: 'vocals'
```

**Expected behavior**

I cannot find consensus on the RTTM format, however, pyannote  refers to the name a uri, and the code within NeMo expects space separated fields.  I would expect the unique name generated from the filename to be uri-compliant.

**Environment overview (please complete the following information)**

 - Python 3.10
 - Ubuntu 22.04 


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

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