Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nglehuy committed May 14, 2024
1 parent 36b070b commit fe33a68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/wiki-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
- uses: actions/[email protected]
- uses: nglehuy/github-wiki-action@master
with:
strategy: clone
token: ${{ secrets.TOKEN }}
path: ./
path: docs
preprocess: true
33 changes: 5 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<h1 align="center">
<p>TensorFlowASR :zap:</p>
TensorFlowASR :zap:
</h1>
<p align="center">
<a href="https://github.com/TensorSpeech/TensorFlowASR/blob/main/LICENSE">
<img alt="GitHub" src="https://img.shields.io/github/license/TensorSpeech/TensorFlowASR?logo=apache&logoColor=green">
Expand All @@ -10,9 +11,8 @@
<img alt="PyPI" src="https://img.shields.io/pypi/v/TensorFlowASR?color=%234285F4&label=release&logo=pypi&logoColor=%234285F4">
</a>
</p>
</h1>
<h2 align="center">
<p>Almost State-of-the-art Automatic Speech Recognition in Tensorflow 2</p>
Almost State-of-the-art Automatic Speech Recognition in Tensorflow 2
</h2>

<p align="center">
Expand Down Expand Up @@ -161,32 +161,9 @@ See [augmentations](./tensorflow_asr/augmentations/README.md)

After converting to tflite, the tflite model is like a function that transforms directly from an **audio signal** to **unicode code points**, then we can convert unicode points to string.

1. Install `tf-nightly` using `pip install tf-nightly`
2. Build a model with the same architecture as the trained model _(if model has tflite argument, you must set it to True)_, then load the weights from trained model to the built model
3. Load `TFSpeechFeaturizer` and `TextFeaturizer` to model using function `add_featurizers`
4. Convert model's function to tflite as follows:

```python
func = model.make_tflite_function(**options) # options are the arguments of the function
concrete_func = func.get_concrete_function()
converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func])
converter.experimental_new_converter = True
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,
tf.lite.OpsSet.SELECT_TF_OPS]
tflite_model = converter.convert()
```

5. Save the converted tflite model as follows:

```python
if not os.path.exists(os.path.dirname(tflite_path)):
os.makedirs(os.path.dirname(tflite_path))
with open(tflite_path, "wb") as tflite_out:
tflite_out.write(tflite_model)
```
See [tflite_convertion](./docs/tutorials/tflite.md)

5. Then the `.tflite` model is ready to be deployed
1. Then the `.tflite` model is ready to be deployed

## Pretrained Models

Expand Down
12 changes: 12 additions & 0 deletions docs/tutorials/tflite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# TFLite Conversion Tutorial

## Run

```bash
python examples/train.py \
--config-path=/path/to/config.yml.j2 \
--h5=/path/to/weight.h5 \
--output=/path/to/output.tflite
## See others params
python examples/tflite.py --help
```

0 comments on commit fe33a68

Please sign in to comment.