speechbrain / speechbrain/speechbrain

Training Speaker_ID SpeechBrain

Open
#2,057 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

I am encountering difficulties while attempting to train the SpeechBrain speaker identification model using my own WAV files. I have made some modifications to the existing code provided in the train.yaml file, but I'm not sure if I'm even modifying the train.py and train.yaml files correctly. I have also saved a json file with annotations in the required format for training.

So far, the code runs well, but nothing is in the 'save' file. I'm hoping to use this code for speaker diarization. It would be great to know what I'm doing correctly and incorrectly to train the model.

Expected behaviour

I was expecting to have a trained model saved in the 'save' file after running %cd /content/speechbrain/templates/speaker_id !python train.py train.yaml --number_of_epochs=15 #--device='cpu' with modified train.py and train.yaml files. I was also expecting to use this model for speaker diarizaitno.

To Reproduce

So far, I've set the data_folder parameter in the train.yaml file to point to my own data directory. In the train.py file, I've updated the prepare_mini_librispeech function call in the main code section to my own data directory.

sb.utils.distributed.run_on_main(
    prepare_mini_librispeech,
    kwargs={
        "data_folder": "file_path",
        "save_json_train": hparams["train_annotation"],
        "save_json_valid": hparams["valid_annotation"],
        "save_json_test": hparams["test_annotation"],
        "split_ratio": hparams["split_ratio"],
    },
)

I've also modified the dataio_prep function to read my own WAV files from the specified directory and replaced the audio_pipeline function with the following code:

import glob

@sb.utils.data_pipeline.takes("file_path")
@sb.utils.data_pipeline.provides("sig")
def audio_pipeline(file_path):
    """Load the signal, and pass it and its length to the corruption class.
    This is done on the CPU in the `collate_fn`."""
    sig = sb.dataio.dataio.read_audio(file_path)
    return sig

# Define datasets. We also connect the dataset with the data processing
# functions defined above.
datasets = {}
data_info = {
    "train": hparams["train_annotation"],
    "valid": hparams["valid_annotation"],
    "test": hparams["test_annotation"],
}
hparams["dataloader_options"]["shuffle"] = False
for dataset in data_info:
    audio_files = glob.glob(os.path.join("file_path", dataset, "*.wav"))
    datasets[dataset] = sb.dataio.dataset.DynamicItemDataset.from_csv(
        csv_path=data_info[dataset],
        replacements={"file_path": audio_files},
        dynamic_items=[audio_pipeline, label_pipeline],
        output_keys=["id", "sig", "spk_id_encoded"],
    )
Versions

No response

Relevant log output

No response

Additional context

No response

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.

Research direction

Start by comparing templates/speaker_id/train.py and train.yaml, especially the prepare_mini_librispeech call, dataio_prep, annotation paths, and save configuration. Run the reported training command with the supplied WAV files and JSON annotations, then verify that the configured save location contains the trained model artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.