Minor improvements for model exporter.

This commit is contained in:
Mateo Cedillo
2023-06-12 17:12:57 -05:00
parent 2a9d86a902
commit aa195db3a8

View File

@@ -5,7 +5,7 @@
"colab": { "colab": {
"provenance": [], "provenance": [],
"gpuType": "T4", "gpuType": "T4",
"authorship_tag": "ABX9TyNIYQxa0c4fzWAKq19kBp4a", "authorship_tag": "ABX9TyOULEPr6wG6WSnjG8EviQHg",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -74,9 +74,9 @@
"guideurl = \"https://github.com/rmcpantoja/piper/blob/master/notebooks/wav/en\"\n", "guideurl = \"https://github.com/rmcpantoja/piper/blob/master/notebooks/wav/en\"\n",
"#@markdown #### Download:\n", "#@markdown #### Download:\n",
"#@markdown **Drive ID or direct download link of the model in another cloud:**\n", "#@markdown **Drive ID or direct download link of the model in another cloud:**\n",
"model_id = \"\" #@param {type:\"string\"}\n", "model_id = \"https://drive.google.com/file/d/1JmphSxbd9YxA9lRb3y5amOX8ah-ald59/view?usp=sharing\" #@param {type:\"string\"}\n",
"#@markdown **Drive ID or direct download link of the config.json file:**\n", "#@markdown **Drive ID or direct download link of the config.json file:**\n",
"config_id = \"\" #@param {type:\"string\"}\n", "config_id = \"1-2Bh3M9oesgKibcXED7k3AALRH9yn7tM\" #@param {type:\"string\"}\n",
"#@markdown ---\n", "#@markdown ---\n",
"\n", "\n",
"#@markdown #### Creation process:\n", "#@markdown #### Creation process:\n",
@@ -91,6 +91,7 @@
"def start_process():\n", "def start_process():\n",
" if not os.path.exists(\"/content/project/model.ckpt\"):\n", " if not os.path.exists(\"/content/project/model.ckpt\"):\n",
" raise Exception(\"Could not download model! make sure the file is shareable to everyone\")\n", " raise Exception(\"Could not download model! make sure the file is shareable to everyone\")\n",
" output.eval_js(f'new Audio(\"{guideurl}/starting.wav?raw=true\").play()')\n",
" !python -m piper_train.export_onnx \"/content/project/model.ckpt\" \"{export_voice_path}/{export_voice_name}.onnx\"\n", " !python -m piper_train.export_onnx \"/content/project/model.ckpt\" \"{export_voice_path}/{export_voice_name}.onnx\"\n",
" print(\"compressing...\")\n", " print(\"compressing...\")\n",
" !tar -czvf \"{packages_path}/voice-{export_voice_name}.tar.gz\" -C \"{export_voice_path}\" .\n", " !tar -czvf \"{packages_path}/voice-{export_voice_name}.tar.gz\" -C \"{export_voice_path}\" .\n",
@@ -118,7 +119,7 @@
"else:\n", "else:\n",
" !wget \"{config_id}\" -O \"{export_voice_path}/{export_voice_name}.onnx.json\"\n", " !wget \"{config_id}\" -O \"{export_voice_path}/{export_voice_name}.onnx.json\"\n",
"#@markdown **Do you want to write a model card?**\n", "#@markdown **Do you want to write a model card?**\n",
"write_model_card = False #@param {type:\"boolean\"}\n", "write_model_card = True #@param {type:\"boolean\"}\n",
"if write_model_card:\n", "if write_model_card:\n",
" with open(f\"{export_voice_path}/{export_voice_name}.onnx.json\", \"r\") as file:\n", " with open(f\"{export_voice_path}/{export_voice_name}.onnx.json\", \"r\") as file:\n",
" config = json.load(file)\n", " config = json.load(file)\n",
@@ -139,7 +140,6 @@
" text_area.close()\n", " text_area.close()\n",
" button.close()\n", " button.close()\n",
" output.clear()\n", " output.clear()\n",
" output.eval_js(f'new Audio(\"{guideurl}/starting.wav?raw=true\").play()')\n",
" start_process()\n", " start_process()\n",
"\n", "\n",
" button.on_click(create_model_card)\n", " button.on_click(create_model_card)\n",
@@ -161,7 +161,7 @@
"#@title Download/export your generated voice package\n", "#@title Download/export your generated voice package\n",
"\n", "\n",
"#@markdown #### How do you want to export your model?\n", "#@markdown #### How do you want to export your model?\n",
"export_mode = \"Download the voice package on my device (may take some time)\" #@param [\"Download the voice package on my device (may take some time)\", \"upload it to my Google Drive\"]\n", "export_mode = \"upload it to my Google Drive\" #@param [\"Download the voice package on my device (may take some time)\", \"upload it to my Google Drive\"]\n",
"print(\"Exporting package...\")\n", "print(\"Exporting package...\")\n",
"if export_mode == \"Download the voice package on my device (may take some time)\":\n", "if export_mode == \"Download the voice package on my device (may take some time)\":\n",
" from google.colab import files\n", " from google.colab import files\n",