{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "gpuType": "T4", "authorship_tag": "ABX9TyOyCiCt4X4oZWyqzQ2fAafX", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "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 = \"\" #@param {type:\"string\"}\n", "#@markdown **Config.json Google Drive ID**\n", "config_id = \"1-7qJ-Aw8OmqKgxxG8o_onU_Rwn0xfIOj\" #@param {type:\"string\"}\n", "#@markdown ---\n", "\n", "#@markdown #### Creation process:\n", "language = \"es\" #@param [\"en-us\", \"es\", \"fr\"]\n", "voice_name = \"Dabe\" #@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", "%cd /content/project\n", "!tar -czvf \"{packages_path}/voice-{export_voice_name}.tar.gz\" \"voice-{export_voice_name}\"" ], "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": [] } ] }