WeSpeaker Python Binding
This is a python binding of WeSpeaker.
WeSpeaker is a production first and production ready end-to-end speaker recognition toolkit.
- Two onnx models are available: voxceleb model, cnceleb_model
- Extract embedding from wav file or feature(Fbank/MFCC).
- Support using
kaldiioto save embedding.
Install
Python 3.6+ is required.
pip3 install wespeakerruntime
Usage
Extract embedding from wav file
import sys
import wespeakerruntime as wespeaker
wav_file = sys.argv[1]
speaker = wespeaker.Speaker(lang='chs')
ans = speaker.extract_embedding(wav_file)
print(ans)
You can also specify the following parameter in wespeaker.Speaker
onnx_path(str, optional): is the path ofonnx model.- Default: onnx model will be downloaded from the server.
lang(str):chsfor cnceleb_model.enfor voxceleb model.inter_op_num_threadsandintra_op_num_threads(int): the number of threads during the model runing. For details, please see: https://onnxruntime.ai/docs/
The parameters of extract_embedding
wav_path(str): the path of wavresample_rate(int): resampling rate. Default: 16000num_mel_bins(int): dimension of fbank. Default: 80frame_length(int): frame length. Default: 25frame_shift(int): frame shift. Default: 10cmn(bool): if true, cepstrum average normalization is applied. Default: True
Compute cosine score
import wespeakerruntime as wespeaker
speaker = wespeaker.Speaker(lang='chs')
emb1 = speaker.extract_embedding_wav(wav1_path)
emb2 = speaker.extract_embedding_wav(wav2_path)
score = speaker.compute_cosine_score(emb1, emb2)
The parameters of compute_cosine_score:
emb1(numpy.ndarray): embedding of speaker-1emb2(numpy.ndarray): embedding of speaker-2
[Optional] Extract embedding from feature(fbank/MFCC)
import sys
import wespeakerruntime as wespeaker
feat = your_fbank
speaker = wespeaker.Speaker(lang='chs')
ans = speaker.extract_embedding_feat(feat)
print(ans)
The parameters of extract_embedding_feat:
feats(numpy.ndarray): the shape is [B, T, D].cmn(bool): if true, cepstrum average normalization is applied. Default: True
[Optional] Extract embedding from wav.scp
import sys
import wespeakerruntime as wespeaker
wav_scp = sys.argv[1]
speaker = wespeaker.Speaker(lang='chs')
speaker.extract_embedding_kaldiio(wav_scp, 'embed.ark')
The parameters of extract_embedding_kaldiio:
wav_path(str): the path of wavembed_ark(str): the path of$ouput.arkresample_rate(int): resampling rate. Default: 16000num_mel_bins(int): dimension of fbank. Default: 80frame_length(int): frame length. Default: 25frame_shift(int): frame shift. Default: 10cmn(bool): if true, cepstrum average normalization is applied. Default: True
Build on Your Local Machine
git clone git@github.com:wenet-e2e/wespeaker.git
cd wespeaker/runtime/binding/python
python setup.py install
Metadata
Release files for wespeakerruntime 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wespeakerruntime-1.0.1.tar.gz | 5.4 kB | Without provenance | Details for wespeakerruntime-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wespeakerruntime-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for wespeakerruntime-1.0.1-py3-none-any.whl |
Total release size: 11.6 kB
Release files / wespeakerruntime-1.0.1.tar.gz
| Download URL | wespeakerruntime-1.0.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
863e0e72bfb8a1271c6192aa6c1f90e89c72fb353aff44a1fd19764d0191f343
|
|
BLAKE2b-256 checksum How to use checksums |
3ff113ac146a127c1fd5cc4806e51498758db68c287005d9161e0076499a1f57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Release files / wespeakerruntime-1.0.1-py3-none-any.whl
| Download URL | wespeakerruntime-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
862eafc82f8d788ea2bb30ccdbd519b82019b75725399dcf3b0db388e87600da
|
|
BLAKE2b-256 checksum How to use checksums |
54468e5cb4453fe0ae17762ab0ac029e259f3a2ddbd8ce7eaaf321cba35f8acd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Security for wespeakerruntime 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.