README.md 10.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
([简体中文](./README_cn.md)|English)
# Speech Verification)

## Introduction

Speaker Verification, refers to the problem of getting a speaker embedding from an audio. 

This demo is an implementation to extract speaker embedding from a specific audio file. It can be done by a single command or a few lines in python using `PaddleSpeech`. 

## Usage
### 1. Installation
see [installation](https://github.com/PaddlePaddle/PaddleSpeech/blob/develop/docs/source/install.md).

You can choose one way from easy, meduim and hard to install paddlespeech.

### 2. Prepare Input File
The input of this demo should be a WAV file(`.wav`), and the sample rate must be the same as the model.

Here are sample files for this demo that can be downloaded:
```bash
wget -c https://paddlespeech.bj.bcebos.com/vector/audio/85236145389.wav
```

### 3. Usage
- Command Line(Recommended)
  ```bash
  paddlespeech vector --task spk --input 85236145389.wav

  echo -e "demo1 85236145389.wav" > vec.job
  paddlespeech vector --task spk --input vec.job

  echo -e "demo2 85236145389.wav \n demo3 85236145389.wav" | paddlespeech vector --task spk
33 34 35 36 37

  paddlespeech vector --task score --input "./85236145389.wav ./123456789.wav"
  
  echo -e "demo4 85236145389.wav 85236145389.wav \n demo5 85236145389.wav 123456789.wav" > vec.job
  paddlespeech vector --task score --input vec.job
38 39 40 41
  ```
  
  Usage:
  ```bash
42
  paddlespeech vector --help
43 44 45
  ```
  Arguments:
  - `input`(required): Audio file to recognize.
46
  - `task` (required): Specify `vector` task. Default `spk`
47
  - `model`: Model type of vector task. Default: `ecapatdnn_voxceleb12`.
48
  - `sample_rate`: Sample rate of the model. Default: `16000`.
49
  - `config`: Config of vector task. Use pretrained model when it is None. Default: `None`.
50 51 52 53 54
  - `ckpt_path`: Model checkpoint. Use pretrained model when it is None. Default: `None`.
  - `device`: Choose device to execute model inference. Default: default device of paddlepaddle in current environment.

  Output:

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
  ```bash
    demo [ -5.749211     9.505463    -8.200284    -5.2075014    5.3940268
      -3.04878      1.611095    10.127234   -10.534177   -15.821609
      1.2032688   -0.35080156   1.2629458  -12.643498    -2.5758228
    -11.343508     2.3385992   -8.719341    14.213509    15.404744
      -0.39327756   6.338786     2.688887     8.7104025   17.469526
      -8.77959      7.0576906    4.648855    -1.3089896  -23.294737
      8.013747    13.891729    -9.926753     5.655307    -5.9422326
    -22.842539     0.6293588  -18.46266    -10.811862     9.8192625
      3.0070958    3.8072643   -2.3861165    3.0821571  -14.739942
      1.7594414   -0.6485091    4.485623     2.0207152    7.264915
      -6.40137     23.63524      2.9711294  -22.708025     9.93719
      20.354511   -10.324688    -0.700492    -8.783211    -5.27593
      15.999649     3.3004563   12.747926    15.429879     4.7849145
      5.6699696   -2.3826702   10.605882     3.9112158    3.1500628
      15.859915    -2.1832209  -23.908653    -6.4799504   -4.5365124
      -9.224193    14.568347   -10.568833     4.982321    -4.342062
      0.0914714   12.645902    -5.74285     -3.2141201   -2.7173362
      -6.680575     0.4757669   -5.035051    -6.7964664   16.865469
    -11.54324      7.681869     0.44475392   9.708182    -8.932846
      0.4123232   -4.361452     1.3948607    9.511665     0.11667654
      2.9079323    6.049952     9.275183   -18.078873     6.2983274
      -0.7500531   -2.725033    -7.6027865    3.3404543    2.990815
      4.010979    11.000591    -2.8873312    7.1352735  -16.79663
      18.495346   -14.293832     7.89578      2.2714825   22.976387
      -4.875734    -3.0836344   -2.9999814   13.751918     6.448228
    -11.924197     2.171869     2.0423572   -6.173772    10.778437
      25.77281     -4.9495463   14.57806      0.3044315    2.6132357
      -7.591999    -2.076944     9.025118     1.7834753   -3.1799617
      -4.9401326   23.465864     5.1685796   -9.018578     9.037825
      -4.4150195    6.859591   -12.274467    -0.88911164   5.186309
      -3.9988663  -13.638606    -9.925445    -0.06329413  -3.6709652
    -12.397416   -12.719869    -1.395601     2.1150916    5.7381287
      -4.4691963   -3.82819     -0.84233856  -1.1604277  -13.490127
      8.731719   -20.778936   -11.495662     5.8033476   -4.752041
      10.833007    -6.717991     4.504732    13.4244375    1.1306485
      7.3435574    1.400918    14.704036    -9.501399     7.2315617
      -6.417456     1.3333273   11.872697    -0.30664724   8.8845
      6.5569253    4.7948146    0.03662816  -8.704245     6.224871
      -3.2701402  -11.508579  ]
95 96 97 98 99 100 101 102 103 104 105
  ```

- Python API
  ```python
  import paddle
  from paddlespeech.cli import VectorExecutor

  vector_executor = VectorExecutor()
  audio_emb = vector_executor(
      model='ecapatdnn_voxceleb12',
      sample_rate=16000,
106
      config=None,  # Set `config` and `ckpt_path` to None to use pretrained model.
107 108 109 110
      ckpt_path=None,
      audio_file='./85236145389.wav',
      device=paddle.get_device())
  print('Audio embedding Result: \n{}'.format(audio_emb))
111 112 113 114 115 116 117 118 119 120 121

  test_emb = vector_executor(
      model='ecapatdnn_voxceleb12',
      sample_rate=16000,
      config=None,  # Set `config` and `ckpt_path` to None to use pretrained model.
      ckpt_path=None,
      audio_file='./123456789.wav',
      device=paddle.get_device())
  print('Test embedding Result: \n{}'.format(test_emb))
  score = vector_executor.get_embeddings_score(audio_emb, test_emb)
  print(f"Eembeddings Score: {score}")
122 123
  ```

124 125
  Output:

126 127
  ```bash
  # Vector Result:
128
   Audio embedding Result:
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
   [ -5.749211     9.505463    -8.200284    -5.2075014    5.3940268
      -3.04878      1.611095    10.127234   -10.534177   -15.821609
      1.2032688   -0.35080156   1.2629458  -12.643498    -2.5758228
    -11.343508     2.3385992   -8.719341    14.213509    15.404744
      -0.39327756   6.338786     2.688887     8.7104025   17.469526
      -8.77959      7.0576906    4.648855    -1.3089896  -23.294737
      8.013747    13.891729    -9.926753     5.655307    -5.9422326
    -22.842539     0.6293588  -18.46266    -10.811862     9.8192625
      3.0070958    3.8072643   -2.3861165    3.0821571  -14.739942
      1.7594414   -0.6485091    4.485623     2.0207152    7.264915
      -6.40137     23.63524      2.9711294  -22.708025     9.93719
      20.354511   -10.324688    -0.700492    -8.783211    -5.27593
      15.999649     3.3004563   12.747926    15.429879     4.7849145
      5.6699696   -2.3826702   10.605882     3.9112158    3.1500628
      15.859915    -2.1832209  -23.908653    -6.4799504   -4.5365124
      -9.224193    14.568347   -10.568833     4.982321    -4.342062
      0.0914714   12.645902    -5.74285     -3.2141201   -2.7173362
      -6.680575     0.4757669   -5.035051    -6.7964664   16.865469
    -11.54324      7.681869     0.44475392   9.708182    -8.932846
      0.4123232   -4.361452     1.3948607    9.511665     0.11667654
      2.9079323    6.049952     9.275183   -18.078873     6.2983274
      -0.7500531   -2.725033    -7.6027865    3.3404543    2.990815
      4.010979    11.000591    -2.8873312    7.1352735  -16.79663
      18.495346   -14.293832     7.89578      2.2714825   22.976387
      -4.875734    -3.0836344   -2.9999814   13.751918     6.448228
    -11.924197     2.171869     2.0423572   -6.173772    10.778437
      25.77281     -4.9495463   14.57806      0.3044315    2.6132357
      -7.591999    -2.076944     9.025118     1.7834753   -3.1799617
      -4.9401326   23.465864     5.1685796   -9.018578     9.037825
      -4.4150195    6.859591   -12.274467    -0.88911164   5.186309
      -3.9988663  -13.638606    -9.925445    -0.06329413  -3.6709652
    -12.397416   -12.719869    -1.395601     2.1150916    5.7381287
      -4.4691963   -3.82819     -0.84233856  -1.1604277  -13.490127
      8.731719   -20.778936   -11.495662     5.8033476   -4.752041
      10.833007    -6.717991     4.504732    13.4244375    1.1306485
      7.3435574    1.400918    14.704036    -9.501399     7.2315617
      -6.417456     1.3333273   11.872697    -0.30664724   8.8845
      6.5569253    4.7948146    0.03662816  -8.704245     6.224871
      -3.2701402  -11.508579  ]
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
    # get the test embedding
    Test embedding Result:
    [ -1.9617152    4.2184057   -5.4289927    3.8006616    7.400566
      12.844175     1.4330423    0.4860911  -15.927942   -13.081303
      -4.585545     2.378477     5.5894523  -13.060747    18.578707
      -9.107497    -9.904055     0.7032993    0.7945765   -1.4118854
      -6.4434266   -2.7688267    5.4320455    2.9636188   23.857662
      -4.797293    22.821133    -1.6718386    0.80379957 -10.28131
      -1.0586771    5.840774   -11.794188     0.9715659  -10.794272
      -9.9839325   11.916608   -19.614918    -7.38727     12.361765
    -15.568076     3.796782     1.4648503   -9.617965     1.8912128
      5.5519567    4.1027875    9.565811     1.6652825   -0.06557167
      7.3765106    6.91407     -3.4179301    4.676896     2.4507313
      21.415924    -1.5271066    0.7630236  -15.634208   -24.682417
      12.035311     1.9669697  -13.733474    11.616938   -16.630692
    -16.287516    -7.4265285   -6.4809394    5.4794173   -8.481719
      2.0745668   -7.50969      1.8279544  -15.189501    -4.000386
      -1.5209727    6.975059     4.518711     3.0962887   -6.8465433
      1.3825562    7.6983547   -9.399815    -7.3269534   -2.6540608
      1.3231711    5.0338726   -5.9562182  -10.437971    19.123528
      12.213971    -2.8820174  -20.65914     15.071251     8.114322
      -4.045127     7.5128584   -3.3306584    6.822803    -0.05004288
      -4.4368496   18.926466    14.04377     -5.9657135    4.714744
      10.24277     -3.848245    14.494125     5.3582125   -6.30404
    -14.122616     2.1969411   -5.90989      9.3047      -8.431231
      10.438023   -11.987487    20.954517    -4.279951    -0.3756797
      13.041809    -6.051407   -10.529183     3.7894943   -1.6330183
      6.743382    -0.19549051   7.315633   -19.438568     0.6115422
      4.5697403    2.1208212    0.52282465  -6.9142766   -5.8893275
      0.5135903    0.92921656  -3.0571883   -7.4849505    2.2382743
      -3.0478394    0.08785366   6.810543    -5.1137877   15.182398
      -6.9418297   -8.922732    -2.4528694    7.324874    19.77244
      13.997188    -5.08692    -14.329076    -6.1807523   -1.8777156
      -3.6879017    6.3892293   -3.78877    -13.009837   -16.838747
      -4.1660237   -7.4346085    0.5579437   -2.8482168  -13.509024
      9.329142     8.1292095   -8.064337    -4.002228   -18.78694
      7.7969575  -13.585645    -5.8225474   15.266658    -8.57028
      -7.449079     2.2094946   28.004955    -3.0901644   11.932054
      -1.5897936   -4.826059     6.9232755  -11.169697    -5.235409
      11.251503     2.105524     4.0860977   -0.5384147   19.023642
      1.6203141  -10.608387  ]
    # get the score between enroll and test
    Eembeddings Score: 0.3965281546115875
211 212 213 214 215 216 217 218 219
  ```

### 4.Pretrained Models

Here is a list of pretrained models released by PaddleSpeech that can be used by command and python API:

| Model | Sample Rate
| :--- | :---: |
| ecapatdnn_voxceleb12 | 16k