mirror of
https://github.com/snakers4/silero-vad.git
synced 2026-02-05 18:09:22 +08:00
Merge branch 'master' of https://github.com/snakers4/silero-vad
This commit is contained in:
41
README.md
41
README.md
@@ -114,6 +114,7 @@ model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
|
|||||||
force_reload=True)
|
force_reload=True)
|
||||||
|
|
||||||
(get_speech_ts,
|
(get_speech_ts,
|
||||||
|
get_speech_ts_adaptive,
|
||||||
_, read_audio,
|
_, read_audio,
|
||||||
_, _, _) = utils
|
_, _, _) = utils
|
||||||
|
|
||||||
@@ -122,9 +123,15 @@ files_dir = torch.hub.get_dir() + '/snakers4_silero-vad_master/files'
|
|||||||
wav = read_audio(f'{files_dir}/en.wav')
|
wav = read_audio(f'{files_dir}/en.wav')
|
||||||
# full audio
|
# full audio
|
||||||
# get speech timestamps from full audio file
|
# get speech timestamps from full audio file
|
||||||
|
|
||||||
|
# classic way
|
||||||
speech_timestamps = get_speech_ts(wav, model,
|
speech_timestamps = get_speech_ts(wav, model,
|
||||||
num_steps=4)
|
num_steps=4)
|
||||||
pprint(speech_timestamps)
|
pprint(speech_timestamps)
|
||||||
|
|
||||||
|
# adaptive way
|
||||||
|
speech_timestamps = get_speech_ts_adaptive(wav, model)
|
||||||
|
pprint(speech_timestamps)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Number Detector
|
#### Number Detector
|
||||||
@@ -195,6 +202,7 @@ _, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
|
|||||||
force_reload=True)
|
force_reload=True)
|
||||||
|
|
||||||
(get_speech_ts,
|
(get_speech_ts,
|
||||||
|
get_speech_ts_adaptive,
|
||||||
_, read_audio,
|
_, read_audio,
|
||||||
_, _, _) = utils
|
_, _, _) = utils
|
||||||
|
|
||||||
@@ -208,14 +216,20 @@ def validate_onnx(model, inputs):
|
|||||||
ort_inputs = {'input': inputs.cpu().numpy()}
|
ort_inputs = {'input': inputs.cpu().numpy()}
|
||||||
outs = model.run(None, ort_inputs)
|
outs = model.run(None, ort_inputs)
|
||||||
outs = [torch.Tensor(x) for x in outs]
|
outs = [torch.Tensor(x) for x in outs]
|
||||||
return outs
|
return outs[0]
|
||||||
|
|
||||||
model = init_onnx_model(f'{files_dir}/model.onnx')
|
model = init_onnx_model(f'{files_dir}/model.onnx')
|
||||||
wav = read_audio(f'{files_dir}/en.wav')
|
wav = read_audio(f'{files_dir}/en.wav')
|
||||||
|
|
||||||
# get speech timestamps from full audio file
|
# get speech timestamps from full audio file
|
||||||
|
|
||||||
|
# classic way
|
||||||
speech_timestamps = get_speech_ts(wav, model, num_steps=4, run_function=validate_onnx)
|
speech_timestamps = get_speech_ts(wav, model, num_steps=4, run_function=validate_onnx)
|
||||||
pprint(speech_timestamps)
|
pprint(speech_timestamps)
|
||||||
|
|
||||||
|
# adaptive way
|
||||||
|
speech_timestamps = get_speech_ts(wav, model, run_function=validate_onnx)
|
||||||
|
pprint(speech_timestamps)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Number Detector
|
#### Number Detector
|
||||||
@@ -337,7 +351,7 @@ We use random 250 ms audio chunks for validation. Speech to non-speech ratio amo
|
|||||||
|
|
||||||
Since our VAD (only VAD, other networks are more flexible) was trained on chunks of the same length, model's output is just one float from 0 to 1 - **speech probability**. We use speech probabilities as thresholds for precision-recall curve. This can be extended to 100 - 150 ms. Less than 100 - 150 ms cannot be distinguished as speech with confidence.
|
Since our VAD (only VAD, other networks are more flexible) was trained on chunks of the same length, model's output is just one float from 0 to 1 - **speech probability**. We use speech probabilities as thresholds for precision-recall curve. This can be extended to 100 - 150 ms. Less than 100 - 150 ms cannot be distinguished as speech with confidence.
|
||||||
|
|
||||||
[Webrtc](https://github.com/wiseman/py-webrtcvad) splits audio into frames, each frame has corresponding number (0 **or** 1). We use 30ms frames for webrtc, so each 250 ms chunk is split into 8 frames, their **mean** value is used as a treshold for plot.
|
[Webrtc](https://github.com/wiseman/py-webrtcvad) splits audio into frames, each frame has corresponding number (0 **or** 1). We use 30ms frames for webrtc, so each 250 ms chunk is split into 8 frames, their **mean** value is used as a threshold for plot.
|
||||||
|
|
||||||
[Auditok](https://github.com/amsehili/auditok) - logic same as Webrtc, but we use 50ms frames.
|
[Auditok](https://github.com/amsehili/auditok) - logic same as Webrtc, but we use 50ms frames.
|
||||||
|
|
||||||
@@ -347,6 +361,9 @@ Since our VAD (only VAD, other networks are more flexible) was trained on chunks
|
|||||||
|
|
||||||
### VAD Parameter Fine Tuning
|
### VAD Parameter Fine Tuning
|
||||||
|
|
||||||
|
#### **Classic way**
|
||||||
|
|
||||||
|
**This is straightforward classic method `get_speech_ts` where thresholds (`trig_sum` and `neg_trig_sum`) are specified by users**
|
||||||
- Among others, we provide several [utils](https://github.com/snakers4/silero-vad/blob/8b28767292b424e3e505c55f15cd3c4b91e4804b/utils.py#L52-L59) to simplify working with VAD;
|
- Among others, we provide several [utils](https://github.com/snakers4/silero-vad/blob/8b28767292b424e3e505c55f15cd3c4b91e4804b/utils.py#L52-L59) to simplify working with VAD;
|
||||||
- We provide sensible basic hyper-parameters that work for us, but your case can be different;
|
- We provide sensible basic hyper-parameters that work for us, but your case can be different;
|
||||||
- `trig_sum` - overlapping windows are used for each audio chunk, trig sum defines average probability among those windows for switching into triggered state (speech state);
|
- `trig_sum` - overlapping windows are used for each audio chunk, trig sum defines average probability among those windows for switching into triggered state (speech state);
|
||||||
@@ -365,6 +382,24 @@ speech_timestamps = get_speech_ts(wav, model,
|
|||||||
visualize_probs=True)
|
visualize_probs=True)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### **Adaptive way**
|
||||||
|
|
||||||
|
**Adaptive algorithm (`get_speech_ts_adaptive`) automatically selects thresholds (`trig_sum` and `neg_trig_sum`) based on median speech probabilities over the whole audio, SOME ARGUMENTS VARY FROM THE CLASSIC WAY FUNCTION ARGUMENTS**
|
||||||
|
- `batch_size` - batch size to feed to silero VAD (default - `200`)
|
||||||
|
- `step` - step size in samples, (default - `500`) (`num_samples_per_window` / `num_steps` from classic method)
|
||||||
|
- `num_samples_per_window` - number of samples in each window, our models were trained using `4000` samples (250 ms) per window, so this is preferable value (lesser values reduce [quality](https://github.com/snakers4/silero-vad/issues/2#issuecomment-750840434));
|
||||||
|
- `min_speech_samples` - minimum speech chunk duration in samples (default - `10000`)
|
||||||
|
- `min_silence_samples` - minimum silence duration in samples between to separate speech chunks (default - `4000`)
|
||||||
|
- `speech_pad_samples` - widen speech by this amount of samples each side (default - `2000`)
|
||||||
|
|
||||||
|
```
|
||||||
|
speech_timestamps = get_speech_ts_adaptive(wav, model,
|
||||||
|
num_samples_per_window=4000,
|
||||||
|
step=500,
|
||||||
|
visualize_probs=True)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
The chart should looks something like this:
|
The chart should looks something like this:
|
||||||
|
|
||||||

|

|
||||||
@@ -390,7 +425,7 @@ Please see [Quality Metrics](#quality-metrics)
|
|||||||
### How Number Detector Works
|
### How Number Detector Works
|
||||||
|
|
||||||
- It is recommended to split long audio into short ones (< 15s) and apply model on each of them;
|
- It is recommended to split long audio into short ones (< 15s) and apply model on each of them;
|
||||||
- Number Detector can classify if whole audio contains a number, or if each audio frame contains a number;
|
- Number Detector can classify if the whole audio contains a number, or if each audio frame contains a number;
|
||||||
- Audio is splitted into frames in a certain way, so, having a per-frame output, we can restore timing bounds for a numbers with an accuracy of about 0.2s;
|
- Audio is splitted into frames in a certain way, so, having a per-frame output, we can restore timing bounds for a numbers with an accuracy of about 0.2s;
|
||||||
|
|
||||||
### How Language Classifier Works
|
### How Language Classifier Works
|
||||||
|
|||||||
337
silero-vad.ipynb
Executable file → Normal file
337
silero-vad.ipynb
Executable file → Normal file
@@ -12,7 +12,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"id": "FpMplOCA2Fwp"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## VAD"
|
"## VAD"
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true
|
"id": "62A6F_072Fwq"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -32,11 +32,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"hidden": true,
|
||||||
"end_time": "2020-12-30T17:35:43.397137Z",
|
"id": "5w5AkskZ2Fwr"
|
||||||
"start_time": "2020-12-30T17:33:10.962078Z"
|
|
||||||
},
|
|
||||||
"hidden": true
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -57,6 +54,7 @@
|
|||||||
" force_reload=True)\n",
|
" force_reload=True)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"(get_speech_ts,\n",
|
"(get_speech_ts,\n",
|
||||||
|
" get_speech_ts_adaptive,\n",
|
||||||
" save_audio,\n",
|
" save_audio,\n",
|
||||||
" read_audio,\n",
|
" read_audio,\n",
|
||||||
" state_generator,\n",
|
" state_generator,\n",
|
||||||
@@ -69,23 +67,25 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
|
||||||
"hidden": true,
|
|
||||||
"id": "fXbbaUO3jsrw"
|
"id": "fXbbaUO3jsrw"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Full Audio"
|
"### Full Audio"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "dY2Us3_Q2Fws"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the thresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-30T17:35:44.362860Z",
|
|
||||||
"start_time": "2020-12-30T17:35:43.398441Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
|
||||||
"id": "aI_eydBPjsrx"
|
"id": "aI_eydBPjsrx"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -101,11 +101,6 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-30T17:35:44.419280Z",
|
|
||||||
"start_time": "2020-12-30T17:35:44.364175Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
|
||||||
"id": "OuEobLchjsry"
|
"id": "OuEobLchjsry"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -119,23 +114,62 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"id": "n8plzbJU2Fws"
|
||||||
"hidden": true,
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorithm selects thresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "SQOtu2Vl2Fwt"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"wav = read_audio(f'{files_dir}/en.wav')\n",
|
||||||
|
"# get speech timestamps from full audio file\n",
|
||||||
|
"speech_timestamps = get_speech_ts_adaptive(wav, model, step=500, num_samples_per_window=4000)\n",
|
||||||
|
"pprint(speech_timestamps)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "Lr6zCGXh2Fwt"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# merge all speech chunks to one audio\n",
|
||||||
|
"save_audio('only_speech.wav',\n",
|
||||||
|
" collect_chunks(speech_timestamps, wav), 16000) \n",
|
||||||
|
"Audio('only_speech.wav')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
"id": "iDKQbVr8jsry"
|
"id": "iDKQbVr8jsry"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Single Audio Stream"
|
"### Single Audio Stream"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "xCM-HrUR2Fwu"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the thresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:59.199321Z",
|
|
||||||
"start_time": "2020-12-15T13:09:59.196823Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
|
||||||
"id": "q-lql_2Wjsry"
|
"id": "q-lql_2Wjsry"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -147,11 +181,34 @@
|
|||||||
" print(batch)"
|
" print(batch)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "t8TXtnvk2Fwv"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorithm selects thresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "BX3UgwwB2Fwv"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"wav = f'{files_dir}/en.wav'\n",
|
||||||
|
"\n",
|
||||||
|
"for batch in single_audio_stream(model, wav, iterator_type='adaptive'):\n",
|
||||||
|
" if batch:\n",
|
||||||
|
" print(batch)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
|
||||||
"id": "KBDVybJCjsrz"
|
"id": "KBDVybJCjsrz"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
@@ -162,10 +219,6 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:10:03.590358Z",
|
|
||||||
"start_time": "2020-12-15T13:10:03.587071Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "BK4tGfWgjsrz"
|
"id": "BK4tGfWgjsrz"
|
||||||
},
|
},
|
||||||
@@ -179,10 +232,6 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:10:15.762491Z",
|
|
||||||
"start_time": "2020-12-15T13:10:03.591388Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "v1l8sam1jsrz"
|
"id": "v1l8sam1jsrz"
|
||||||
},
|
},
|
||||||
@@ -196,7 +245,8 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"id": "36jY0niD2Fww"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Number detector"
|
"## Number detector"
|
||||||
@@ -206,7 +256,8 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "scd1DlS42Fwx"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -216,7 +267,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "Kq5gQuYq2Fwx"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -249,7 +301,8 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "qhPa30ij2Fwy"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Full audio"
|
"### Full audio"
|
||||||
@@ -259,7 +312,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "EXpau6xq2Fwy"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -273,7 +327,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "u-KfXRhZ2Fwy"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -288,7 +343,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "iwYEC4aZ2Fwy"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -302,7 +358,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "fHaYejX12Fwy"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -315,7 +372,8 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"id": "PnKtJKbq2Fwz"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Language detector"
|
"## Language detector"
|
||||||
@@ -325,7 +383,8 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "F5cAmMbP2Fwz"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -335,7 +394,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "Zu9D0t6n2Fwz"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -365,7 +425,8 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "iC696eMX2Fwz"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Full audio"
|
"### Full audio"
|
||||||
@@ -375,7 +436,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "c8UYnYBF2Fw0"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -396,7 +458,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"id": "hEhnfORV2Fw0"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## VAD"
|
"## VAD"
|
||||||
@@ -406,7 +468,6 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
|
||||||
"id": "bL4kn4KJrlyL"
|
"id": "bL4kn4KJrlyL"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
@@ -439,6 +500,7 @@
|
|||||||
" force_reload=True)\n",
|
" force_reload=True)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"(get_speech_ts,\n",
|
"(get_speech_ts,\n",
|
||||||
|
" get_speech_ts_adaptive,\n",
|
||||||
" save_audio,\n",
|
" save_audio,\n",
|
||||||
" read_audio,\n",
|
" read_audio,\n",
|
||||||
" state_generator,\n",
|
" state_generator,\n",
|
||||||
@@ -461,23 +523,25 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
|
||||||
"hidden": true,
|
|
||||||
"id": "5JHErdB7jsr0"
|
"id": "5JHErdB7jsr0"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Full Audio"
|
"### Full Audio"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "TNEtK5zi2Fw2"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the thresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:06.643812Z",
|
|
||||||
"start_time": "2020-12-15T13:09:06.473386Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
|
||||||
"id": "krnGoA6Kjsr0"
|
"id": "krnGoA6Kjsr0"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -494,11 +558,6 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:08.862421Z",
|
|
||||||
"start_time": "2020-12-15T13:09:08.820014Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
|
||||||
"id": "B176Lzfnjsr1"
|
"id": "B176Lzfnjsr1"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -511,23 +570,63 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"id": "21RE8KEC2Fw2"
|
||||||
"hidden": true,
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorithm selects thresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "uIVs56rb2Fw2"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"model = init_onnx_model(f'{files_dir}/model.onnx')\n",
|
||||||
|
"wav = read_audio(f'{files_dir}/en.wav')\n",
|
||||||
|
"\n",
|
||||||
|
"# get speech timestamps from full audio file\n",
|
||||||
|
"speech_timestamps = get_speech_ts_adaptive(wav, model, run_function=validate_onnx) \n",
|
||||||
|
"pprint(speech_timestamps)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "cox6oumC2Fw3"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# merge all speech chunks to one audio\n",
|
||||||
|
"save_audio('only_speech.wav', collect_chunks(speech_timestamps, wav), 16000)\n",
|
||||||
|
"Audio('only_speech.wav')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
"id": "Rio9W50gjsr1"
|
"id": "Rio9W50gjsr1"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Single Audio Stream"
|
"### Single Audio Stream"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "i8EZwtaA2Fw3"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the thresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:09.606031Z",
|
|
||||||
"start_time": "2020-12-15T13:09:09.504239Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
|
||||||
"id": "IPkl8Yy1jsr1"
|
"id": "IPkl8Yy1jsr1"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -540,11 +639,6 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:11.453171Z",
|
|
||||||
"start_time": "2020-12-15T13:09:09.633435Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
|
||||||
"id": "NC6Jim0hjsr1"
|
"id": "NC6Jim0hjsr1"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -554,11 +648,44 @@
|
|||||||
" pprint(batch)"
|
" pprint(batch)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "0pSKslpz2Fw3"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorithm selects thresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "RZwc-Khk2Fw4"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"model = init_onnx_model(f'{files_dir}/model.onnx')\n",
|
||||||
|
"wav = f'{files_dir}/en.wav'"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"id": "Z4lzFPs02Fw4"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"for batch in single_audio_stream(model, wav, iterator_type='adaptive', run_function=validate_onnx):\n",
|
||||||
|
" if batch:\n",
|
||||||
|
" pprint(batch)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
|
||||||
"id": "WNZ42u0ajsr1"
|
"id": "WNZ42u0ajsr1"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
@@ -569,10 +696,6 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:11.540423Z",
|
|
||||||
"start_time": "2020-12-15T13:09:11.455706Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "XjhGQGppjsr1"
|
"id": "XjhGQGppjsr1"
|
||||||
},
|
},
|
||||||
@@ -587,10 +710,6 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:19.565434Z",
|
|
||||||
"start_time": "2020-12-15T13:09:11.552097Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "QI7-arlqjsr2"
|
"id": "QI7-arlqjsr2"
|
||||||
},
|
},
|
||||||
@@ -604,7 +723,8 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"id": "7QMvUvpg2Fw4"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Number detector"
|
"## Number detector"
|
||||||
@@ -615,7 +735,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "bL4kn4KJrlyL"
|
"id": "tBPDkpHr2Fw4"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -625,13 +745,9 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-30T17:25:19.107534Z",
|
|
||||||
"start_time": "2020-12-30T17:24:51.853293Z"
|
|
||||||
},
|
|
||||||
"cellView": "form",
|
"cellView": "form",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "Q4QIfSpprnkI"
|
"id": "PdjGd56R2Fw5"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -675,7 +791,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "5JHErdB7jsr0"
|
"id": "I9QWSFZh2Fw5"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Full Audio"
|
"### Full Audio"
|
||||||
@@ -685,12 +801,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:06.643812Z",
|
|
||||||
"start_time": "2020-12-15T13:09:06.473386Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "krnGoA6Kjsr0"
|
"id": "_r6QZiwu2Fw5"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -706,7 +818,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "FN4aDwLV2Fw5"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -721,12 +834,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-15T13:09:08.862421Z",
|
|
||||||
"start_time": "2020-12-15T13:09:08.820014Z"
|
|
||||||
},
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "B176Lzfnjsr1"
|
"id": "JnvS6WTK2Fw5"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -740,7 +849,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "yUxOcOFG2Fw6"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -753,7 +863,8 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"id": "SR8Bgcd52Fw6"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Language detector"
|
"## Language detector"
|
||||||
@@ -764,7 +875,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "bL4kn4KJrlyL"
|
"id": "PBnXPtKo2Fw6"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -774,13 +885,9 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2020-12-30T17:25:19.107534Z",
|
|
||||||
"start_time": "2020-12-30T17:24:51.853293Z"
|
|
||||||
},
|
|
||||||
"cellView": "form",
|
"cellView": "form",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "Q4QIfSpprnkI"
|
"id": "iNkDWJ3H2Fw6"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -819,9 +926,8 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "5JHErdB7jsr0"
|
"id": "G8N8oP4q2Fw6"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Full Audio"
|
"### Full Audio"
|
||||||
@@ -831,7 +937,8 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "WHXnh9IV2Fw6"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -863,7 +970,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.8.3"
|
"version": "3.8.8"
|
||||||
},
|
},
|
||||||
"toc": {
|
"toc": {
|
||||||
"base_numbering": 1,
|
"base_numbering": 1,
|
||||||
@@ -880,5 +987,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 1
|
"nbformat_minor": 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user