{"id":16909522,"url":"https://github.com/juanmc2005/speakerembeddinglosscomparison","last_synced_at":"2025-10-08T16:36:03.529Z","repository":{"id":103071262,"uuid":"248780101","full_name":"juanmc2005/SpeakerEmbeddingLossComparison","owner":"juanmc2005","description":"Companion repository for the paper \"A Comparison of Metric Learning Loss Functions for End-to-End Speaker Verification\" published at SLSP 2020","archived":false,"fork":false,"pushed_at":"2020-10-07T07:51:07.000Z","size":16832,"stargazers_count":60,"open_issues_count":1,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-08-27T08:40:24.877Z","etag":null,"topics":["additive-angular-margin-loss","end-to-end-machine-learning","metric-learning","pytorch","sincnet","speaker-embedding","speaker-verification","x-vector"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2003.14021","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juanmc2005.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-20T14:48:38.000Z","updated_at":"2025-05-23T18:15:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"1c7795bc-b79f-4124-8a72-22ee80532048","html_url":"https://github.com/juanmc2005/SpeakerEmbeddingLossComparison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/juanmc2005/SpeakerEmbeddingLossComparison","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanmc2005%2FSpeakerEmbeddingLossComparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanmc2005%2FSpeakerEmbeddingLossComparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanmc2005%2FSpeakerEmbeddingLossComparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanmc2005%2FSpeakerEmbeddingLossComparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juanmc2005","download_url":"https://codeload.github.com/juanmc2005/SpeakerEmbeddingLossComparison/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanmc2005%2FSpeakerEmbeddingLossComparison/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278978908,"owners_count":26079370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["additive-angular-margin-loss","end-to-end-machine-learning","metric-learning","pytorch","sincnet","speaker-embedding","speaker-verification","x-vector"],"created_at":"2024-10-13T18:56:04.978Z","updated_at":"2025-10-08T16:36:03.507Z","avatar_url":"https://github.com/juanmc2005.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Comparison of Metric Learning Loss Functions for End-to-End Speaker Verification\n\nThis is the companion repository for the paper [A Comparison of Metric Learning Loss Functions for End-to-End Speaker Verification](https://arxiv.org/abs/2003.14021), published at the [SLSP 2020](https://irdta.eu/slsp2020/) conference. It hosts our best model trained with additive angular margin loss, and contains instructions for reproducing our results and using the model.\n\n## Architecture\n\n![Architecture](images/architecture.png?raw=true \"Architecture\")\n\nThe architecture of our model consists of [SincNet](https://arxiv.org/abs/1808.00158) for feature extraction followed by [x-vector](https://www.danielpovey.com/files/2018_icassp_xvectors.pdf).\n\n## Training\n\nYou can train our model from scratch using the configuration file `config.yml` that we provide. All you need to do is run the following commands in your terminal:\n\n```console\n$ export EXP=models/AAM # Replace with the new path to config.yml\n$ export PROTOCOL=VoxCeleb.SpeakerVerification.VoxCeleb2\n$ pyannote-audio emb train --parallel=10 --gpu --to=1000 $EXP $PROTOCOL \n```\n\nNote that you may need to change parameters based on your setup.\n\n## Evaluation\n\nWe provide a step-by-step guide on reproducing our equal error rates alongside their 95% confidence intervals. The guide first evaluates the pretrained model using raw cosine distances, and then improves it with adaptive s-norm score normalization.\n\nIf you want to reproduce our results, check out [this notebook](https://github.com/juanmc2005/SpeakerEmbeddingLossComparison/blob/master/reproduce.ipynb)\n\n## Fine-tuning\n\nYou can fine-tune our model to your dataset with the following commands:\n\n```console\n$ export WEIGHTS=models/AAM/train/VoxCeleb.SpeakerVerification.VoxCeleb2.train/weights/0560.pt\n$ export EXP=\u003cyour_experiment_directory\u003e\n$ export PROTOCOL=\u003cyour_pyannote_database_protocol\u003e\n$ pyannote-audio emb train --pretrained $WEIGHTS --gpu --to=1000 $EXP $PROTOCOL\n```\n\n## Inference in Python\n\nThe default pyannote model for speaker embedding on `torch.hub` is our AAM loss model trained on variable length audio chunks. If you want to use the model right away, you can do so easily in a Python script:\n\n```python\n# load pretrained model from torch.hub\nimport torch\nmodel = torch.hub.load('pyannote/pyannote-audio', 'emb')\n\n# extract embeddings for the whole files\nemb1 = model({'audio': '/path/to/file1.wav'})\nemb2 = model({'audio': '/path/to/file2.wav'})\n\n# compute distance between embeddings\nfrom scipy.spatial.distance import cdist\nimport numpy as np\ndistance = np.mean(cdist(emb1, emb2, metric='cosine'))\n```\n\nYou can also replace the call to `torch.hub.load` with a pyannote `Pretrained` instance pointing to the model in this repo:\n\n```python\nfrom pyannote.audio.features import Pretrained\nmodel = Pretrained(\n    'models/AAM/train/VoxCeleb.SpeakerVerification.VoxCeleb2.train/validate_equal_error_rate/'\n    'VoxCeleb.SpeakerVerification.VoxCeleb1_X.development', step=0.0333)\n\nprint(f'Embeddings of {model.sliding_window.duration:g}s duration and of dimension {model.dimension:d}, '\n      f'extracted every {1000 * model.sliding_window.step:g}ms')\n```\n\n## Some Compatibility Notes\n\nThis project depends on the [pyannote-audio](https://github.com/pyannote/pyannote-audio) toolkit, so make sure you install it before running any code.\n\nUnder normal circumstances, everything should work with the newest version of pyannote. However, given that pyannote is constantly evolving, some compatibility issues may appear. To make sure these don't happen, you can install the version at [this commit](https://github.com/pyannote/pyannote-audio/commit/562b74e4e2c7c2e97ad8eaabd1c95015c7e41e16) from the `develop` branch.\n\n## Citation\n\nIf our work has been useful to you, please cite our paper:\n\n```bibtex\n@InProceedings{10.1007/978-3-030-59430-5_11,\n    author=\"Coria, Juan M.\n    and Bredin, Herv{\\'e}\n    and Ghannay, Sahar\n    and Rosset, Sophie\",\n    editor=\"Espinosa-Anke, Luis\n    and Mart{\\'i}n-Vide, Carlos\n    and Spasi{\\'{c}}, Irena\",\n    title=\"{A Comparison of Metric Learning Loss Functions for End-To-End Speaker Verification}\",\n    booktitle=\"Statistical Language and Speech Processing\",\n    year=\"2020\",\n    publisher=\"Springer International Publishing\",\n    address=\"Cham\",\n    pages=\"137--148\",\n    isbn=\"978-3-030-59430-5\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuanmc2005%2Fspeakerembeddinglosscomparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuanmc2005%2Fspeakerembeddinglosscomparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuanmc2005%2Fspeakerembeddinglosscomparison/lists"}