mirror of
https://github.com/dscripka/openWakeWord.git
synced 2026-08-27 18:17:20 -04:00
Updated requirements for full installation automatic training notebook example [skip ci]
This commit is contained in:
parent
e9fd49d533
commit
da8c3c9ec8
2 changed files with 69 additions and 6 deletions
|
|
@ -68,11 +68,35 @@
|
|||
"!git clone https://github.com/rhasspy/piper-sample-generator\n",
|
||||
"!wget -O piper-sample-generator/models/en_US-libritts_r-medium.pt 'https://github.com/rhasspy/piper-sample-generator/releases/download/v2.0.0/en_US-libritts_r-medium.pt'\n",
|
||||
"!pip install piper-phonemize\n",
|
||||
"!pip install webrtcvad\n",
|
||||
"\n",
|
||||
"# install openwakeword (full installation to support training)\n",
|
||||
"!git clone --branch auto_training https://github.com/dscripka/openwakeword\n",
|
||||
"!pip install -e ./openwakeword[full]\n",
|
||||
"!cd openwakeword\n"
|
||||
"!git clone https://github.com/dscripka/openwakeword\n",
|
||||
"!pip install -e ./openwakeword\n",
|
||||
"!cd openwakeword\n",
|
||||
"\n",
|
||||
"# install other dependencies\n",
|
||||
"!pip install mutagen==1.47.0\n",
|
||||
"!pip install torchinfo==1.8.0\n",
|
||||
"!pip install torchmetrics==1.2.0\n",
|
||||
"!pip install speechbrain==0.5.14\n",
|
||||
"!pip install audiomentations==0.33.0\n",
|
||||
"!pip install torch-audiomentations==0.11.0\n",
|
||||
"!pip install acoustics==0.2.6\n",
|
||||
"!pip install tensorflow-cpu==2.8.1\n",
|
||||
"!pip install tensorflow_probability==0.16.0\n",
|
||||
"!pip install onnx_tf==1.10.0\n",
|
||||
"!pip install pronouncing==0.2.0\n",
|
||||
"!pip install datasets==2.14.6\n",
|
||||
"!pip install deep-phonemizer==0.0.19\n",
|
||||
"\n",
|
||||
"# Download required models (workaround for Colab)\n",
|
||||
"import os\n",
|
||||
"os.makedirs(\"./openwakeword/openwakeword/resources/models\")\n",
|
||||
"!wget https://github.com/dscripka/openWakeWord/releases/download/v0.5.1/embedding_model.onnx -O ./openwakeword/openwakeword/resources/models/embedding_model.onnx\n",
|
||||
"!wget https://github.com/dscripka/openWakeWord/releases/download/v0.5.1/embedding_model.tflite -O ./openwakeword/openwakeword/resources/models/embedding_model.tflite\n",
|
||||
"!wget https://github.com/dscripka/openWakeWord/releases/download/v0.5.1/melspectrogram.onnx -O ./openwakeword/openwakeword/resources/models/melspectrogram.onnx\n",
|
||||
"!wget https://github.com/dscripka/openWakeWord/releases/download/v0.5.1/melspectrogram.tflite -O ./openwakeword/openwakeword/resources/models/melspectrogram.tflite\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -390,10 +414,49 @@
|
|||
"!{sys.executable} openwakeword/openwakeword/train.py --training_config my_model.yaml --train_model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Step 4 (Optional): On Google Colab, sometimes the .tflite model isn't saved correctly\n",
|
||||
"# If so, run this cell to retry\n",
|
||||
"\n",
|
||||
"# Manually save to tflite as this doesn't work right in colab\n",
|
||||
"def convert_onnx_to_tflite(onnx_model_path, output_path):\n",
|
||||
" \"\"\"Converts an ONNX version of an openwakeword model to the Tensorflow tflite format.\"\"\"\n",
|
||||
" # imports\n",
|
||||
" import onnx\n",
|
||||
" import logging\n",
|
||||
" import tempfile\n",
|
||||
" from onnx_tf.backend import prepare\n",
|
||||
" import tensorflow as tf\n",
|
||||
"\n",
|
||||
" # Convert to tflite from onnx model\n",
|
||||
" onnx_model = onnx.load(onnx_model_path)\n",
|
||||
" tf_rep = prepare(onnx_model, device=\"CPU\")\n",
|
||||
" with tempfile.TemporaryDirectory() as tmp_dir:\n",
|
||||
" tf_rep.export_graph(os.path.join(tmp_dir, \"tf_model\"))\n",
|
||||
" converter = tf.lite.TFLiteConverter.from_saved_model(os.path.join(tmp_dir, \"tf_model\"))\n",
|
||||
" tflite_model = converter.convert()\n",
|
||||
"\n",
|
||||
" logging.info(f\"####\\nSaving tflite mode to '{output_path}'\")\n",
|
||||
" with open(output_path, 'wb') as f:\n",
|
||||
" f.write(tflite_model)\n",
|
||||
"\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
"convert_onnx_to_tflite(f\"my_custom_model/{config['model_name']}.onnx\", f\"my_custom_model/{config['model_name']}.tflite\")\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "JSKWWLalnYzR"
|
||||
},
|
||||
"id": "JSKWWLalnYzR",
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"After the model finishes training, the auto training script will automatically convert it to ONNX and tflite versions, saving them as `<model_name>.onnx/tflite` in the present working directory, where `<model_name>` is defined in the YAML training config file. Either version can be used as normal with `openwakeword`. I recommend testing them with the [`detect_from_microphone.py`](https://github.com/dscripka/openWakeWord/blob/main/examples/detect_from_microphone.py) example script to see how the model performs!"
|
||||
"After the model finishes training, the auto training script will automatically convert it to ONNX and tflite versions, saving them as `my_custom_model/<model_name>.onnx/tflite` in the present working directory, where `<model_name>` is defined in the YAML training config file. Either version can be used as normal with `openwakeword`. I recommend testing them with the [`detect_from_microphone.py`](https://github.com/dscripka/openWakeWord/blob/main/examples/detect_from_microphone.py) example script to see how the model performs!"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "f9OyUW3ltOSs"
|
||||
|
|
|
|||
4
setup.py
4
setup.py
|
|
@ -50,7 +50,7 @@ setuptools.setup(
|
|||
],
|
||||
'full': [
|
||||
'mutagen>=1.46.0,<2',
|
||||
'torch>=1.13.1,<2',
|
||||
'torch>=1.13.1,<3',
|
||||
'torchaudio>=0.13.1,<1',
|
||||
'torchinfo>=1.8.0,<2',
|
||||
'torchmetrics>=0.11.4,<1',
|
||||
|
|
@ -64,7 +64,7 @@ setuptools.setup(
|
|||
'pytest-mypy>=0.10.0,<1',
|
||||
'acoustics>=0.2.6,<1',
|
||||
'pyyaml>=6.0,<7',
|
||||
'tensorflow==2.8.1',
|
||||
'tensorflow-cpu==2.8.1',
|
||||
'tensorflow_probability==0.16.0',
|
||||
'protobuf>=3.20,<4',
|
||||
'onnx_tf==1.10.0',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue