mirror of
https://github.com/snakers4/silero-vad.git
synced 2026-02-05 18:09:22 +08:00
37
README.md
37
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
|
||||||
@@ -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 tresholds (`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 algorythm (`get_speech_ts_adaptive`) automatically selects tresholds (`trig_sum` and `neg_trig_sum`) based on median speech probabilities over whole audio, SOME ARGUMENTS VARY FROM 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:
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
301
silero-vad.ipynb
Executable file → Normal file
301
silero-vad.ipynb
Executable file → Normal file
@@ -3,6 +3,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"heading_collapsed": true,
|
||||||
"id": "sVNOuHQQjsrp"
|
"id": "sVNOuHQQjsrp"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
@@ -12,7 +13,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"hidden": true,
|
||||||
|
"id": "FpMplOCA2Fwp"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## VAD"
|
"## VAD"
|
||||||
@@ -22,7 +25,8 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "62A6F_072Fwq"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -36,7 +40,8 @@
|
|||||||
"end_time": "2020-12-30T17:35:43.397137Z",
|
"end_time": "2020-12-30T17:35:43.397137Z",
|
||||||
"start_time": "2020-12-30T17:33:10.962078Z"
|
"start_time": "2020-12-30T17:33:10.962078Z"
|
||||||
},
|
},
|
||||||
"hidden": true
|
"hidden": true,
|
||||||
|
"id": "5w5AkskZ2Fwr"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -57,6 +62,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",
|
||||||
@@ -77,6 +83,16 @@
|
|||||||
"### Full Audio"
|
"### Full Audio"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"id": "dY2Us3_Q2Fws"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the tresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -116,6 +132,46 @@
|
|||||||
"Audio('only_speech.wav')"
|
"Audio('only_speech.wav')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"id": "n8plzbJU2Fws"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorythm selects tresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"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": {
|
||||||
|
"hidden": true,
|
||||||
|
"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",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -127,6 +183,20 @@
|
|||||||
"### Single Audio Stream"
|
"### Single Audio Stream"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2021-04-15T13:29:04.224833Z",
|
||||||
|
"start_time": "2021-04-15T13:29:04.220588Z"
|
||||||
|
},
|
||||||
|
"hidden": true,
|
||||||
|
"id": "xCM-HrUR2Fwu"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the tresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -147,6 +217,32 @@
|
|||||||
" print(batch)"
|
" print(batch)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"id": "t8TXtnvk2Fwv"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorythm selects tresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"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": {
|
||||||
@@ -196,7 +292,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"hidden": true,
|
||||||
|
"id": "36jY0niD2Fww"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Number detector"
|
"## Number detector"
|
||||||
@@ -206,7 +304,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 +315,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 +349,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 +360,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 +375,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 +391,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 +406,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 +420,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"hidden": true,
|
||||||
|
"id": "PnKtJKbq2Fwz"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Language detector"
|
"## Language detector"
|
||||||
@@ -325,7 +432,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 +443,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 +474,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 +485,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": [
|
||||||
@@ -387,6 +498,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"heading_collapsed": true,
|
||||||
"id": "57avIBd6jsrz"
|
"id": "57avIBd6jsrz"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
@@ -396,7 +508,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"hidden": true,
|
||||||
|
"id": "hEhnfORV2Fw0"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## VAD"
|
"## VAD"
|
||||||
@@ -417,6 +531,10 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2021-04-15T13:30:22.938755Z",
|
||||||
|
"start_time": "2021-04-15T13:30:20.970574Z"
|
||||||
|
},
|
||||||
"cellView": "form",
|
"cellView": "form",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "Q4QIfSpprnkI"
|
"id": "Q4QIfSpprnkI"
|
||||||
@@ -439,6 +557,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",
|
||||||
@@ -469,13 +588,27 @@
|
|||||||
"### Full Audio"
|
"### Full Audio"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2021-04-15T13:34:22.554010Z",
|
||||||
|
"start_time": "2021-04-15T13:34:22.550308Z"
|
||||||
|
},
|
||||||
|
"hidden": true,
|
||||||
|
"id": "TNEtK5zi2Fw2"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the tresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2020-12-15T13:09:06.643812Z",
|
"end_time": "2021-04-15T13:30:14.475412Z",
|
||||||
"start_time": "2020-12-15T13:09:06.473386Z"
|
"start_time": "2021-04-15T13:30:14.427933Z"
|
||||||
},
|
},
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "krnGoA6Kjsr0"
|
"id": "krnGoA6Kjsr0"
|
||||||
@@ -508,6 +641,51 @@
|
|||||||
"Audio('only_speech.wav')"
|
"Audio('only_speech.wav')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"id": "21RE8KEC2Fw2"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorythm selects tresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"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": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2021-04-15T13:34:41.375446Z",
|
||||||
|
"start_time": "2021-04-15T13:34:41.368055Z"
|
||||||
|
},
|
||||||
|
"hidden": true,
|
||||||
|
"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",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -519,6 +697,16 @@
|
|||||||
"### Single Audio Stream"
|
"### Single Audio Stream"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"id": "i8EZwtaA2Fw3"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Classic way of getting speech chunks, you may need to select the tresholds yourself**"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -554,6 +742,43 @@
|
|||||||
" pprint(batch)"
|
" pprint(batch)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"id": "0pSKslpz2Fw3"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"**Experimental Adaptive method, algorythm selects tresholds itself (see readme for more information)**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"hidden": true,
|
||||||
|
"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": {
|
||||||
|
"hidden": true,
|
||||||
|
"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": {
|
||||||
@@ -604,7 +829,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"hidden": true,
|
||||||
|
"id": "7QMvUvpg2Fw4"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Number detector"
|
"## Number detector"
|
||||||
@@ -615,7 +842,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "bL4kn4KJrlyL"
|
"id": "tBPDkpHr2Fw4"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -631,7 +858,7 @@
|
|||||||
},
|
},
|
||||||
"cellView": "form",
|
"cellView": "form",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "Q4QIfSpprnkI"
|
"id": "PdjGd56R2Fw5"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -675,7 +902,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "5JHErdB7jsr0"
|
"id": "I9QWSFZh2Fw5"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Full Audio"
|
"### Full Audio"
|
||||||
@@ -690,7 +917,7 @@
|
|||||||
"start_time": "2020-12-15T13:09:06.473386Z"
|
"start_time": "2020-12-15T13:09:06.473386Z"
|
||||||
},
|
},
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "krnGoA6Kjsr0"
|
"id": "_r6QZiwu2Fw5"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -706,7 +933,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": [
|
||||||
@@ -726,7 +954,7 @@
|
|||||||
"start_time": "2020-12-15T13:09:08.820014Z"
|
"start_time": "2020-12-15T13:09:08.820014Z"
|
||||||
},
|
},
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "B176Lzfnjsr1"
|
"id": "JnvS6WTK2Fw5"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -740,7 +968,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 +982,9 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true
|
"heading_collapsed": true,
|
||||||
|
"hidden": true,
|
||||||
|
"id": "SR8Bgcd52Fw6"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"## Language detector"
|
"## Language detector"
|
||||||
@@ -764,7 +995,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"heading_collapsed": true,
|
"heading_collapsed": true,
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "bL4kn4KJrlyL"
|
"id": "PBnXPtKo2Fw6"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Install Dependencies"
|
"### Install Dependencies"
|
||||||
@@ -780,7 +1011,7 @@
|
|||||||
},
|
},
|
||||||
"cellView": "form",
|
"cellView": "form",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"id": "Q4QIfSpprnkI"
|
"id": "iNkDWJ3H2Fw6"
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -819,9 +1050,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 +1061,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 +1094,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 +1111,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 1
|
"nbformat_minor": 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user