Skip to content

Commit 1a855a3

Browse files
committed
Fx TF examples
1 parent af3426a commit 1a855a3

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ print(decoded)
151151
```python
152152
import os
153153
import torch
154+
import subprocess
154155
import tensorflow as tf
155156
import tensorflow_hub as tf_hub
156157
from omegaconf import OmegaConf
@@ -169,7 +170,9 @@ available_languages = list(models.stt_models.keys())
169170
assert language in available_languages
170171

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

174177
# download a single file, any format compatible with TorchAudio (soundfile backend)
175178
torch.hub.download_url_to_file('https://opus-codec.org/static/examples/samples/speech_orig.wav', dst ='speech_orig.wav', progress=True)

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
- [Plans](#plans)
22
- [Updates](#updates)
3+
- [2020-11-26 Fix TensorFlow Examples](#2020-11-26-fix-tensorflow-examples)
34
- [2020-11-03 [Experimental] Ukrainian Model V1 Released](#2020-11-03-experimental-ukrainian-model-v1-released)
45
- [2020-11-03 English Model V2 Released](#2020-11-03-english-model-v2-released)
56
- [2020-10-28 Minor PyTorch 1.7 fix](#2020-10-28-minor-pytorch-17-fix)
@@ -31,6 +32,8 @@ General plans w/o any set dates:
3132

3233
# Updates
3334

35+
## 2020-11-26 Fix TensorFlow Examples
36+
3437
## 2020-11-03 [Experimental] Ukrainian Model V1 Released
3538

3639
- An experimental model

examples.ipynb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@
542542
"\n",
543543
"import os\n",
544544
"import torch\n",
545+
"import subprocess\n",
545546
"import tensorflow as tf\n",
546547
"import tensorflow_hub as tf_hub\n",
547548
"from omegaconf import OmegaConf"
@@ -584,10 +585,21 @@
584585
"torch.hub.download_url_to_file('https://raw.githubusercontent.com/snakers4/silero-models/master/models.yml', 'models.yml')\n",
585586
"models = OmegaConf.load('models.yml')\n",
586587
"available_languages = list(models.stt_models.keys())\n",
587-
"assert language in available_languages\n",
588-
"\n",
588+
"assert language in available_languages"
589+
]
590+
},
591+
{
592+
"cell_type": "code",
593+
"execution_count": null,
594+
"metadata": {
595+
"id": "1hzUo933PdLF"
596+
},
597+
"outputs": [],
598+
"source": [
589599
"# load the actual tf model\n",
590-
"tf_model = tf_hub.load(models.stt_models.en.latest.tf)"
600+
"torch.hub.download_url_to_file(models.stt_models.en.latest.tf, 'tf_model.tar.gz')\n",
601+
"subprocess.run('rm -rf tf_model && mkdir tf_model && tar xzfv tf_model.tar.gz -C tf_model', shell=True, check=True)\n",
602+
"tf_model = tf.saved_model.load('tf_model')"
591603
]
592604
},
593605
{

0 commit comments

Comments
 (0)