Skip to content

Commit

Permalink
Fx TF examples
Browse files Browse the repository at this point in the history
  • Loading branch information
snakers4 committed Nov 26, 2020
1 parent af3426a commit 1a855a3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ print(decoded)
```python
import os
import torch
import subprocess
import tensorflow as tf
import tensorflow_hub as tf_hub
from omegaconf import OmegaConf
Expand All @@ -169,7 +170,9 @@ available_languages = list(models.stt_models.keys())
assert language in available_languages

# load the actual tf model
tf_model = tf_hub.load(models.stt_models.en.latest.tf)
torch.hub.download_url_to_file(models.stt_models.en.latest.tf, 'tf_model.tar.gz')
subprocess.run('rm -rf tf_model && mkdir tf_model && tar xzfv tf_model.tar.gz -C tf_model', shell=True, check=True)
tf_model = tf.saved_model.load('tf_model')

# download a single file, any format compatible with TorchAudio (soundfile backend)
torch.hub.download_url_to_file('https://opus-codec.org/static/examples/samples/speech_orig.wav', dst ='speech_orig.wav', progress=True)
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- [Plans](#plans)
- [Updates](#updates)
- [2020-11-26 Fix TensorFlow Examples](#2020-11-26-fix-tensorflow-examples)
- [2020-11-03 [Experimental] Ukrainian Model V1 Released](#2020-11-03-experimental-ukrainian-model-v1-released)
- [2020-11-03 English Model V2 Released](#2020-11-03-english-model-v2-released)
- [2020-10-28 Minor PyTorch 1.7 fix](#2020-10-28-minor-pytorch-17-fix)
Expand Down Expand Up @@ -31,6 +32,8 @@ General plans w/o any set dates:

# Updates

## 2020-11-26 Fix TensorFlow Examples

## 2020-11-03 [Experimental] Ukrainian Model V1 Released

- An experimental model
Expand Down
18 changes: 15 additions & 3 deletions examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
"\n",
"import os\n",
"import torch\n",
"import subprocess\n",
"import tensorflow as tf\n",
"import tensorflow_hub as tf_hub\n",
"from omegaconf import OmegaConf"
Expand Down Expand Up @@ -584,10 +585,21 @@
"torch.hub.download_url_to_file('https://raw.githubusercontent.com/snakers4/silero-models/master/models.yml', 'models.yml')\n",
"models = OmegaConf.load('models.yml')\n",
"available_languages = list(models.stt_models.keys())\n",
"assert language in available_languages\n",
"\n",
"assert language in available_languages"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1hzUo933PdLF"
},
"outputs": [],
"source": [
"# load the actual tf model\n",
"tf_model = tf_hub.load(models.stt_models.en.latest.tf)"
"torch.hub.download_url_to_file(models.stt_models.en.latest.tf, 'tf_model.tar.gz')\n",
"subprocess.run('rm -rf tf_model && mkdir tf_model && tar xzfv tf_model.tar.gz -C tf_model', shell=True, check=True)\n",
"tf_model = tf.saved_model.load('tf_model')"
]
},
{
Expand Down

0 comments on commit 1a855a3

Please sign in to comment.