mirror of
https://github.com/pstrueb/piper.git
synced 2026-05-09 14:58:01 +00:00
Added model exporter notebook.
This commit is contained in:
118
notebooks/piper_model_exporter.ipynb
Normal file
118
notebooks/piper_model_exporter.ipynb
Normal file
@@ -0,0 +1,118 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": [],
|
||||
"gpuType": "T4",
|
||||
"authorship_tag": "ABX9TyMkrP91PCGT541xgO1Y2fSe",
|
||||
"include_colab_link": true
|
||||
},
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
},
|
||||
"accelerator": "GPU",
|
||||
"gpuClass": "standard"
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "view-in-github",
|
||||
"colab_type": "text"
|
||||
},
|
||||
"source": [
|
||||
"<a href=\"https://colab.research.google.com/github/rmcpantoja/piper/blob/master/notebooks/piper_model_exporter.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# [Piper](https://github.com/rhasspy/piper) model exporter\n",
|
||||
"\n",
|
||||
"Notebook created by [rmcpantoja](http://github.com/rmcpantoja)"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "EOL-kjplZYEU"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"cellView": "form",
|
||||
"id": "FfMKr8v2RVOm"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#@title Install software\n",
|
||||
"#@markdown **Note: Please restart the runtime environment if prompted, and then continue to the next cell.**\n",
|
||||
"!git clone https://github.com/rhasspy/piper\n",
|
||||
"%cd /content/piper/src/python\n",
|
||||
"!pip install --upgrade pip\n",
|
||||
"!pip install --upgrade wheel setuptools\n",
|
||||
"!pip install cython>=0.29.0 espeak-phonemizer>=1.1.0 librosa>=0.9.2 numpy>=1.19.0 pytorch-lightning~=1.7.0 torch~=1.11.0\n",
|
||||
"!pip install onnx onnxruntime-gpu\n",
|
||||
"!bash build_monotonic_align.sh\n",
|
||||
"!apt-get install espeak-ng\n",
|
||||
"!pip install torchtext==0.12.0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"#@title Voice package generation section\n",
|
||||
"%cd /content/piper/src/python\n",
|
||||
"import os\n",
|
||||
"#@markdown #### Download:\n",
|
||||
"#@markdown **Google Drive model ID:**\n",
|
||||
"model_id = \"1KTwFwDy17RdPDT2qDJsyty__rt3KviZZ\" #@param {type:\"string\"}\n",
|
||||
"#@markdown **Config.json Google Drive ID**\n",
|
||||
"config_id = \"1-hEqdUetfaqrSYZF8hB75Y-9ZR0S--qa\" #@param {type:\"string\"}\n",
|
||||
"#@markdown ---\n",
|
||||
"\n",
|
||||
"#@markdown #### Creation process:\n",
|
||||
"language = \"en-us\" #@param [\"en-us\", \"es\", \"fr\"]\n",
|
||||
"voice_name = \"Joe\" #@param {type:\"string\"}\n",
|
||||
"voice_name = voice_name.lower()\n",
|
||||
"quality = \"medium\" #@param [\"high\", \"low\", \"medium\", \"x-low\"]\n",
|
||||
"export_voice_name = f\"{language}-{voice_name}-{quality}\"\n",
|
||||
"export_voice_path = \"/content/project/voice-\"+export_voice_name\n",
|
||||
"packages_path = \"/content/project/packages\"\n",
|
||||
"if not os.path.exists(export_voice_path):\n",
|
||||
" os.makedirs(export_voice_path)\n",
|
||||
"if not os.path.exists(packages_path):\n",
|
||||
" os.makedirs(packages_path)\n",
|
||||
"!gdown \"{model_id}\" -O /content/project/model.ckpt\n",
|
||||
"!gdown \"{config_id}\" -O \"{export_voice_path}/{export_voice_name}.onnx.json\"\n",
|
||||
"!python -m piper_train.export_onnx \"/content/project/model.ckpt\" \"{export_voice_path}/{export_voice_name}.onnx\"\n",
|
||||
"print(\"compressing...\")\n",
|
||||
"!tar -czvf \"{packages_path}/voice-{export_voice_name}.tar.gz\" \"{export_voice_path}\""
|
||||
],
|
||||
"metadata": {
|
||||
"cellView": "form",
|
||||
"id": "PqcoBb26V5xA"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"#@title Download generated voice package\n",
|
||||
"from google.colab import files\n",
|
||||
"files.download(f\"{packages_path}/voice-{export_voice_name}.tar.gz\")"
|
||||
],
|
||||
"metadata": {
|
||||
"cellView": "form",
|
||||
"id": "Hu3V9CJeWc4Y"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user