{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "KhKhMZSzUMTw" }, "source": [ "# MAKE SURE YOU RUN THE CELL IN ORDER!\n" ] }, { "cell_type": "markdown", "metadata": { "id": "ToPD6zvQuXCE" }, "source": [ "# Check GPU\n", "\n", "First, if you want, you can check to see which GPU is currently being used. The best GPUs are P100, V100, and T4. If you get a K80 or P4, you can restart the runtime and try again if you'd like, but all GPUs will (probably) work with this notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "nXzIEAZRuR0Q", "outputId": "053b9568-ed8d-48f8-c22b-cb232ab1b33c" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "GPU 0: Tesla T4 (UUID: GPU-23435e64-200d-1d49-54c4-6aeb65827cad)\n" ] } ], "source": [ "!nvidia-smi -L" ] }, { "cell_type": "code", "source": [ "!pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "0n2ofhozqFpu", "outputId": "74bcd38b-3061-4eee-d562-6bff1d192c01" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Looking in indexes: https://download.pytorch.org/whl/cu124\n", "Collecting torch==2.5.1\n", " Downloading https://download.pytorch.org/whl/cu124/torch-2.5.1%2Bcu124-cp311-cp311-linux_x86_64.whl (908.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m908.3/908.3 MB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting torchvision==0.20.1\n", " Downloading https://download.pytorch.org/whl/cu124/torchvision-0.20.1%2Bcu124-cp311-cp311-linux_x86_64.whl (7.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.3/7.3 MB\u001b[0m \u001b[31m57.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting torchaudio==2.5.1\n", " Downloading https://download.pytorch.org/whl/cu124/torchaudio-2.5.1%2Bcu124-cp311-cp311-linux_x86_64.whl (3.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m58.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (3.18.0)\n", "Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (4.14.0)\n", "Requirement already satisfied: networkx in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (3.5)\n", "Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (3.1.6)\n", "Requirement already satisfied: fsspec in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (2025.3.2)\n", "Collecting nvidia-cuda-nvrtc-cu12==12.4.127 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cuda_nvrtc_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (24.6 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m67.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-cuda-runtime-cu12==12.4.127 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cuda_runtime_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (883 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m60.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-cuda-cupti-cu12==12.4.127 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cuda_cupti_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (13.8 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m113.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-cudnn-cu12==9.1.0.70 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl (664.8 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m1.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-cublas-cu12==12.4.5.8 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cublas_cu12-12.4.5.8-py3-none-manylinux2014_x86_64.whl (363.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-cufft-cu12==11.2.1.3 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cufft_cu12-11.2.1.3-py3-none-manylinux2014_x86_64.whl (211.5 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-curand-cu12==10.3.5.147 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_curand_cu12-10.3.5.147-py3-none-manylinux2014_x86_64.whl (56.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m13.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-cusolver-cu12==11.6.1.9 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cusolver_cu12-11.6.1.9-py3-none-manylinux2014_x86_64.whl (127.9 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m7.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting nvidia-cusparse-cu12==12.3.1.170 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_cusparse_cu12-12.3.1.170-py3-none-manylinux2014_x86_64.whl (207.5 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m6.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: nvidia-nccl-cu12==2.21.5 in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (2.21.5)\n", "Requirement already satisfied: nvidia-nvtx-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (12.4.127)\n", "Collecting nvidia-nvjitlink-cu12==12.4.127 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/cu124/nvidia_nvjitlink_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (21.1 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m98.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting triton==3.1.0 (from torch==2.5.1)\n", " Downloading https://download.pytorch.org/whl/triton-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (209.5 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m209.5/209.5 MB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: sympy==1.13.1 in /usr/local/lib/python3.11/dist-packages (from torch==2.5.1) (1.13.1)\n", "Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from torchvision==0.20.1) (2.0.2)\n", "Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/local/lib/python3.11/dist-packages (from torchvision==0.20.1) (11.2.1)\n", "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from sympy==1.13.1->torch==2.5.1) (1.3.0)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2->torch==2.5.1) (3.0.2)\n", "Installing collected packages: triton, nvidia-nvjitlink-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, nvidia-cusparse-cu12, nvidia-cudnn-cu12, nvidia-cusolver-cu12, torch, torchvision, torchaudio\n", " Attempting uninstall: triton\n", " Found existing installation: triton 3.2.0\n", " Uninstalling triton-3.2.0:\n", " Successfully uninstalled triton-3.2.0\n", " Attempting uninstall: nvidia-nvjitlink-cu12\n", " Found existing installation: nvidia-nvjitlink-cu12 12.5.82\n", " Uninstalling nvidia-nvjitlink-cu12-12.5.82:\n", " Successfully uninstalled nvidia-nvjitlink-cu12-12.5.82\n", " Attempting uninstall: nvidia-curand-cu12\n", " Found existing installation: nvidia-curand-cu12 10.3.6.82\n", " Uninstalling nvidia-curand-cu12-10.3.6.82:\n", " Successfully uninstalled nvidia-curand-cu12-10.3.6.82\n", " Attempting uninstall: nvidia-cufft-cu12\n", " Found existing installation: nvidia-cufft-cu12 11.2.3.61\n", " Uninstalling nvidia-cufft-cu12-11.2.3.61:\n", " Successfully uninstalled nvidia-cufft-cu12-11.2.3.61\n", " Attempting uninstall: nvidia-cuda-runtime-cu12\n", " Found existing installation: nvidia-cuda-runtime-cu12 12.5.82\n", " Uninstalling nvidia-cuda-runtime-cu12-12.5.82:\n", " Successfully uninstalled nvidia-cuda-runtime-cu12-12.5.82\n", " Attempting uninstall: nvidia-cuda-nvrtc-cu12\n", " Found existing installation: nvidia-cuda-nvrtc-cu12 12.5.82\n", " Uninstalling nvidia-cuda-nvrtc-cu12-12.5.82:\n", " Successfully uninstalled nvidia-cuda-nvrtc-cu12-12.5.82\n", " Attempting uninstall: nvidia-cuda-cupti-cu12\n", " Found existing installation: nvidia-cuda-cupti-cu12 12.5.82\n", " Uninstalling nvidia-cuda-cupti-cu12-12.5.82:\n", " Successfully uninstalled nvidia-cuda-cupti-cu12-12.5.82\n", " Attempting uninstall: nvidia-cublas-cu12\n", " Found existing installation: nvidia-cublas-cu12 12.5.3.2\n", " Uninstalling nvidia-cublas-cu12-12.5.3.2:\n", " Successfully uninstalled nvidia-cublas-cu12-12.5.3.2\n", " Attempting uninstall: nvidia-cusparse-cu12\n", " Found existing installation: nvidia-cusparse-cu12 12.5.1.3\n", " Uninstalling nvidia-cusparse-cu12-12.5.1.3:\n", " Successfully uninstalled nvidia-cusparse-cu12-12.5.1.3\n", " Attempting uninstall: nvidia-cudnn-cu12\n", " Found existing installation: nvidia-cudnn-cu12 9.3.0.75\n", " Uninstalling nvidia-cudnn-cu12-9.3.0.75:\n", " Successfully uninstalled nvidia-cudnn-cu12-9.3.0.75\n", " Attempting uninstall: nvidia-cusolver-cu12\n", " Found existing installation: nvidia-cusolver-cu12 11.6.3.83\n", " Uninstalling nvidia-cusolver-cu12-11.6.3.83:\n", " Successfully uninstalled nvidia-cusolver-cu12-11.6.3.83\n", " Attempting uninstall: torch\n", " Found existing installation: torch 2.6.0+cu124\n", " Uninstalling torch-2.6.0+cu124:\n", " Successfully uninstalled torch-2.6.0+cu124\n", " Attempting uninstall: torchvision\n", " Found existing installation: torchvision 0.21.0+cu124\n", " Uninstalling torchvision-0.21.0+cu124:\n", " Successfully uninstalled torchvision-0.21.0+cu124\n", " Attempting uninstall: torchaudio\n", " Found existing installation: torchaudio 2.6.0+cu124\n", " Uninstalling torchaudio-2.6.0+cu124:\n", " Successfully uninstalled torchaudio-2.6.0+cu124\n", "Successfully installed nvidia-cublas-cu12-12.4.5.8 nvidia-cuda-cupti-cu12-12.4.127 nvidia-cuda-nvrtc-cu12-12.4.127 nvidia-cuda-runtime-cu12-12.4.127 nvidia-cudnn-cu12-9.1.0.70 nvidia-cufft-cu12-11.2.1.3 nvidia-curand-cu12-10.3.5.147 nvidia-cusolver-cu12-11.6.1.9 nvidia-cusparse-cu12-12.3.1.170 nvidia-nvjitlink-cu12-12.4.127 torch-2.5.1+cu124 torchaudio-2.5.1+cu124 torchvision-0.20.1+cu124 triton-3.1.0\n" ] } ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "NatDNxccuUmw", "outputId": "7f032c1e-733e-49de-f80f-9a6cacc1f581" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: gdown in /usr/local/lib/python3.11/dist-packages (5.2.0)\n", "Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.11/dist-packages (from gdown) (4.13.4)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from gdown) (3.18.0)\n", "Requirement already satisfied: requests[socks] in /usr/local/lib/python3.11/dist-packages (from gdown) (2.32.3)\n", "Requirement already satisfied: tqdm in /usr/local/lib/python3.11/dist-packages (from gdown) (4.67.1)\n", "Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4->gdown) (2.7)\n", "Requirement already satisfied: typing-extensions>=4.0.0 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4->gdown) (4.14.0)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests[socks]->gdown) (3.4.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests[socks]->gdown) (3.10)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests[socks]->gdown) (2.4.0)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests[socks]->gdown) (2025.4.26)\n", "Requirement already satisfied: PySocks!=1.5.7,>=1.5.6 in /usr/local/lib/python3.11/dist-packages (from requests[socks]->gdown) (1.7.1)\n", "Previous HEAD position was 5bc2a53 README.md: reporting correct number after finding bug in inference time code\n", "HEAD is now at 2fd4e63 README.md: update waveglow speed and published models url\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m235.8/235.8 kB\u001b[0m \u001b[31m7.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting Hebrew\n", " Downloading hebrew-0.8.1-py3-none-any.whl.metadata (11 kB)\n", "Collecting grapheme<0.7.0,>=0.6.0 (from Hebrew)\n", " Downloading grapheme-0.6.0.tar.gz (207 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.3/207.3 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", "Downloading hebrew-0.8.1-py3-none-any.whl (26 kB)\n", "Building wheels for collected packages: grapheme\n", " Building wheel for grapheme (setup.py) ... \u001b[?25l\u001b[?25hdone\n", " Created wheel for grapheme: filename=grapheme-0.6.0-py3-none-any.whl size=210082 sha256=992ae0fa020dbda15092b18e962f73d9a04340dcd8df0b783ce2c509a13dc2de\n", " Stored in directory: /root/.cache/pip/wheels/ee/3b/0b/1b865800e916d671a24028d884698674138632a83fdfad4926\n", "Successfully built grapheme\n", "Installing collected packages: grapheme, Hebrew\n", "Successfully installed Hebrew-0.8.1 grapheme-0.6.0\n" ] } ], "source": [ "#@title Install Tacotron and Waveglow (click to see code)\n", "\n", "import os\n", "from os.path import exists, join, basename, splitext\n", "!pip install gdown\n", "git_repo_url = 'https://github.com/maxmelichov/tacotron2.git'\n", "project_name = splitext(basename(git_repo_url))[0]\n", "if not exists(project_name):\n", " # clone and install\n", " !git clone -q --recursive {git_repo_url}\n", " !cd {project_name}/waveglow && git checkout 2fd4e63\n", " !pip install -q librosa unidecode\n", " !pip install Hebrew\n", "\n", "import sys\n", "sys.path.append(join(project_name, 'waveglow/'))\n", "sys.path.append(project_name)\n", "import time\n", "import matplotlib\n", "import matplotlib.pylab as plt\n", "import gdown\n", "from hebrew import Hebrew\n", "from hebrew.chars import HebrewChar, ALEPH\n", "from hebrew import GematriaTypes\n", "d = 'https://drive.google.com/uc?id='" ] }, { "cell_type": "markdown", "metadata": { "id": "TaPJp2QNut8U" }, "source": [ "The pre-trained model" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "wgu8WXVkuqtD", "outputId": "f2beda4a-d9e2-4d9d-e490-28ab79a43a6d" }, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "Downloading...\n", "From (original): https://drive.google.com/uc?id=13B_NfAw8y-A9pg-xLcP5kQ_7dbObGc8S&export=download\n", "From (redirected): https://drive.google.com/uc?id=13B_NfAw8y-A9pg-xLcP5kQ_7dbObGc8S&export=download&confirm=t&uuid=81cc800c-6d06-4d5f-a62e-3e4d86c998f8\n", "To: /content/MLPTTS\n", "100%|██████████| 338M/338M [00:04<00:00, 83.2MB/s]" ] }, { "output_type": "stream", "name": "stdout", "text": [ "Tacotron2 Model Downloaded\n" ] }, { "output_type": "stream", "name": "stderr", "text": [ "\n" ] } ], "source": [ "#@title Install Tacotron pretrained model (click to see code)\n", "force_download_TT2 = True\n", "tacotron2_pretrained_model = 'MLPTTS'\n", "if not exists(tacotron2_pretrained_model) or force_download_TT2:\n", " # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ PUT MODEL HERE\n", " gdown.download(d+r'13B_NfAw8y-A9pg-xLcP5kQ_7dbObGc8S&export=download', tacotron2_pretrained_model, quiet=False); print(\"Tacotron2 Model Downloaded\")\n", " # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ PUT MODEL HERE" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "f_eOD7Kyu6bu", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "8095a8d4-ea5d-44b1-a946-611247e9c34a" }, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "Downloading...\n", "From (original): https://drive.google.com/uc?id=19CVIL0TL_yyW-qC4jJ2vPht5cxc6VQpO&export=download&authuser=0\n", "From (redirected): https://drive.google.com/uc?id=19CVIL0TL_yyW-qC4jJ2vPht5cxc6VQpO&export=download&authuser=0&confirm=t&uuid=10259320-85b4-4f47-a6c2-acb46c4cd35b\n", "To: /content/waveglow.pt\n", "100%|██████████| 676M/676M [00:06<00:00, 104MB/s]" ] }, { "output_type": "stream", "name": "stdout", "text": [ "WaveGlow Model Downloaded\n" ] }, { "output_type": "stream", "name": "stderr", "text": [ "\n" ] } ], "source": [ "#@title Install Waveglow pretrained (click to see code)\n", "waveglow_pretrained_model = 'waveglow.pt'\n", "if not exists(waveglow_pretrained_model):\n", " gdown.download(d+r'19CVIL0TL_yyW-qC4jJ2vPht5cxc6VQpO&export=download&authuser=0', waveglow_pretrained_model, quiet=False); print(\"WaveGlow Model Downloaded\")#1okuUstGoBe_qZ4qUEF8CcwEugHP7GM_b&export" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "GKkUcNRsu9sr", "outputId": "5e105c72-57db-4537-8da4-09c78af36495" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/content/./tacotron2/waveglow/convert_model.py:69: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", " model = torch.load(old_model_path)\n", "/usr/local/lib/python3.11/dist-packages/torch/serialization.py:1469: SourceChangeWarning: source code of class 'torch.nn.modules.conv.ConvTranspose1d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.\n", " warnings.warn(msg, SourceChangeWarning)\n", "/usr/local/lib/python3.11/dist-packages/torch/serialization.py:1469: SourceChangeWarning: source code of class 'torch.nn.modules.container.ModuleList' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.\n", " warnings.warn(msg, SourceChangeWarning)\n", "/usr/local/lib/python3.11/dist-packages/torch/serialization.py:1469: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv1d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.\n", " warnings.warn(msg, SourceChangeWarning)\n" ] } ], "source": [ "!python ./tacotron2/waveglow/convert_model.py /content/waveglow.pt /content/waveglow.pt" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 35 }, "id": "uvqhtbjru_l-", "outputId": "5a6cb4d8-e466-464e-ff98-12890978a570" }, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "'UTF-8'" ], "application/vnd.google.colaboratory.intrinsic+json": { "type": "string" } }, "metadata": {}, "execution_count": 7 } ], "source": [ "import locale\n", "locale.getpreferredencoding = lambda: \"UTF-8\"\n", "locale.getpreferredencoding()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "cellView": "form", "id": "GAhZ-94-vC70", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "133bd1d9-3052-48ee-f583-7ed67f951ada" }, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "/content/tacotron2/text/__init__.py:74: SyntaxWarning: \"is not\" with a literal. Did you mean \"!=\"?\n", " return s in _symbol_to_id and s is not '_' and s is not '~'\n", "/content/tacotron2/text/__init__.py:74: SyntaxWarning: \"is not\" with a literal. Did you mean \"!=\"?\n", " return s in _symbol_to_id and s is not '_' and s is not '~'\n" ] } ], "source": [ "#@title Initialize Tacotron and Waveglow and Hebrew to English function\n", "%matplotlib inline\n", "import IPython.display as ipd\n", "import numpy as np\n", "import torch\n", "\n", "from hparams import create_hparams\n", "from model import Tacotron2\n", "from layers import TacotronSTFT\n", "from audio_processing import griffin_lim\n", "from text import text_to_sequence\n", "from denoiser import Denoiser\n", "\n", "graph_width = 900\n", "graph_height = 360\n", "def plot_data(data, figsize=(int(graph_width/100), int(graph_height/100))):\n", " %matplotlib inline\n", " fig, axes = plt.subplots(1, len(data), figsize=figsize)\n", " for i in range(len(data)):\n", " axes[i].imshow(data[i], aspect='auto', origin='upper',\n", " interpolation='none', cmap='inferno')\n", " fig.canvas.draw()\n", " plt.show()\n", "\n", "\n", "import re\n", "\n", " ##deals with . and , in a normal string\n", "def break_to_letter_and_rebuild(string):\n", " lst=[]\n", " i=0\n", " flag=False\n", " while i2 and is_number_range(parts[1]+'-'+parts[2]):\n", " return parts[0],(str(parts[1]),str(parts[2])) , \"is_number_range\"\n", "\n", "\n", "\n", "def clean_number(word):\n", "\n", " ## '4,000,' / '10,000' / '1000,'\n", " if is_number_with_comma(word):\n", " return NumberToHebrew(int(clean_number_with_comma(word)))\n", "\n", " ## '2.9' / '3.4'\n", " elif is_number_with_decimal(word):\n", " list_heb=[]\n", " part1,part2=clean_decimal(word)\n", " list_heb+=NumberToHebrew(part1)\n", " list_heb+=NumberToHebrew('.')\n", " list_heb+=NumberToHebrew(part2)\n", " return list_heb\n", "\n", " ## '4.5%' / '9.25%.' / '26.5%,'\n", " elif is_percentage(word):\n", " list_heb = []\n", " part1, part2 = clean_decimal(clean_percentage(word))\n", "\n", " if part2!=None:\n", " list_heb += NumberToHebrew(part1)\n", " list_heb += NumberToHebrew('.')\n", " list_heb += NumberToHebrew(part2)\n", " list_heb += NumberToHebrew('%')\n", " return list_heb\n", " else:\n", " list_heb += NumberToHebrew(part1)\n", " list_heb += NumberToHebrew('%')\n", " return list_heb\n", "\n", " ## '5-6' / '1971-1972,' / '2003-2005.'\n", " elif is_number_range(word):\n", " list_heb = []\n", " part1, part2 = clean_number_range(word)\n", " list_heb += NumberToHebrew(part1)\n", " list_heb.append(\"עַד\")\n", " list_heb += NumberToHebrew(part2)\n", " return list_heb\n", "\n", " ## 'בְּ-100,000' / בְּ-99.99% / הַ-1,100 / מִ-0.7% / לְ-1.9 / כְּ-22,000.\n", " elif is_pattern_number_with_heb(word):\n", " heb_letter,num,func=(clean_pattern_number_with_heb(word))\n", " #arr_attr= (clean_pattern_number_with_heb(word))\n", " list_heb = []\n", " list_heb.append(heb_letter)\n", "\n", " if func==\"is_number_with_comma\":\n", " list_heb+=NumberToHebrew(int(num))\n", " return list_heb\n", "\n", " elif func==\"is_number_with_decimal\":\n", " part1, part2 = num\n", " list_heb += NumberToHebrew(part1)\n", " list_heb += NumberToHebrew('.')\n", " list_heb += NumberToHebrew(part2)\n", " return list_heb\n", "\n", " elif func==\"is_percentage\":\n", " part1, part2 = clean_decimal(num)\n", "\n", " if part2 != None:\n", " list_heb += NumberToHebrew(part1)\n", " list_heb += NumberToHebrew('.')\n", " list_heb += NumberToHebrew(part2)\n", " list_heb += NumberToHebrew('%')\n", " return list_heb\n", " else:\n", " list_heb += NumberToHebrew(part1)\n", " list_heb += NumberToHebrew('%')\n", " return list_heb\n", "\n", " elif func == \"is_number_range\":\n", " part1, part2 = num\n", " list_heb += NumberToHebrew(int(part1))\n", " list_heb.append(\"עַד\")\n", " list_heb += NumberToHebrew(int(part2))\n", " return list_heb\n", "\n", "#######################################################\n", "\n", "##takes a letter in hebrew and returns the sound in english\n", "def HebrewLetterToEnglishSound(obj,tzuptzik,last_letter=False):\n", " obj = Hebrew(obj).string\n", " # map the nikud symbols to their corresponding phenoms\n", " nikud_map = {\"ָ\": \"a\", \"ַ\": \"a\", \"ֶ\": \"e\", \"ֵ\": \"e\", \"ִ\": \"i\", \"ְ\": \"\", \"ֹ\": \"o\", \"ֻ\": \"oo\", 'ּ': \"\", 'ֲ': 'a'}\n", "\n", "\n", " beged_kefet_shin_sin = {\n", " ############ B\n", " \"בּ\": \"b\",\n", " \"בְּ\": \"b\",\n", " \"בִּ\": \"bi\",\n", " \"בֹּ\": \"bo\",\n", " \"בֵּ\": \"be\",\n", " \"בֶּ\": \"be\",\n", " \"בַּ\": \"ba\",\n", " \"בָּ\": \"ba\",\n", " \"בֻּ\": \"boo\",\n", " ############ G\n", " \"גּ\": \"g\",\n", " \"גְּ\": \"g\",\n", " \"גִּ\": \"gi\",\n", " \"גֹּ\": \"go\",\n", " \"גֵּ\": \"ge\",\n", " \"גֶּ\": \"ge\",\n", " \"גַּ\": \"ga\",\n", " \"גָּ\": \"ga\",\n", " \"גֻּ\": \"goo\",\n", " ########### D\n", " \"דּ\": \"d\",\n", " \"דְּ\": \"d\",\n", " \"דִּ\": \"di\",\n", " \"דֹּ\": \"do\",\n", " \"דֵּ\": \"de\",\n", " \"דֶּ\": \"de\",\n", " \"דַּ\": \"da\",\n", " \"דָּ\": \"da\",\n", " \"דֻּ\": \"doo\",\n", " ########### K\n", " \"כּ\": \"k\",\n", " \"כְּ\": \"k\",\n", " \"כִּ\": \"ki\",\n", " \"כֹּ\": \"ko\",\n", " \"כֵּ\": \"ke\",\n", " \"כֶּ\": \"ke\",\n", " \"כַּ\": \"ka\",\n", " \"כָּ\": \"ka\",\n", " \"כֻּ\": \"koo\",\n", " ############ P\n", " \"פּ\": \"p\",\n", " \"פְּ\": \"p\",\n", " \"פִּ\": \"pi\",\n", " \"פֹּ\": \"po\",\n", " \"פֵּ\": \"pe\",\n", " \"פֶּ\": \"pe\",\n", " \"פַּ\": \"pa\",\n", " \"פָּ\": \"pa\",\n", " \"פֻּ\": \"poo\",\n", " ############ T\n", " \"תּ\": \"t\",\n", " \"תְּ\": \"t\",\n", " \"תִּ\": \"ti\",\n", " \"תֹּ\": \"to\",\n", " \"תֵּ\": \"te\",\n", " \"תֶּ\": \"te\",\n", " \"תַּ\": \"ta\",\n", " \"תָּ\": \"ta\",\n", " \"תֻּ\": \"too\",\n", " ############ S\n", " \"שׂ\": \"s\",\n", " \"שְׂ\": \"s\",\n", " \"שִׂ\": \"si\",\n", " \"שֹׂ\": \"so\",\n", " \"שֵׂ\": \"se\",\n", " \"שֶׂ\": \"se\",\n", " \"שַׂ\": \"sa\",\n", " \"שָׂ\": \"sa\",\n", " \"שֻׂ\": \"soo\",\n", " ########### SH\n", " \"שׁ\": \"sh\",\n", " \"שְׁ\": \"sh\",\n", " \"שִׁ\": \"shi\",\n", " \"שֹׁ\": \"sho\",\n", " \"שֵׁ\": \"she\",\n", " \"שֶׁ\": \"she\",\n", " \"שַׁ\": \"sha\",\n", " \"שָׁ\": \"sha\",\n", " \"שֻׁ\": \"shoo\",\n", " }\n", "\n", " vav = {\n", " \"וֵּו\": \"ve\",\n", " \"וּ\": \"oo\",\n", " \"וּו\": \"oo\",\n", " \"וֹ\": \"o\",\n", " \"וֹו\": \"oo\",\n", " \"וְ\": \"ve\",\n", " \"וֱו\": \"ve\",\n", " \"וִ\": \"vi\",\n", " \"וִו\": \"vi\",\n", " \"וַ\": \"va\",\n", " \"וַו\": \"va\",\n", " \"וֶ\": \"ve\",\n", " \"וֶו\": \"ve\",\n", " \"וָ\": \"va\",\n", " \"וָו\": \"va\",\n", " \"וֻ\": \"oo\",\n", " \"וֻו\": \"oo\"\n", " }\n", "\n", "\n", " letters_map = {\n", " \"א\": \"\",\n", " \"ב\": \"v\",\n", " \"ג\": \"g\",\n", " \"ד\": \"d\",\n", " \"ה\": \"hh\",\n", " \"ו\": \"v\",\n", " \"ז\": \"z\",\n", " \"ח\": \"h\",\n", " \"ט\": \"t\",\n", " \"י\": \"y\",\n", " \"כ\": \"h\",\n", " \"ל\": \"l\",\n", " \"מ\": \"m\",\n", " \"נ\": \"n\",\n", " \"ס\": \"s\",\n", " \"ע\": \"\",\n", " \"פ\": \"f\",\n", " \"צ\": \"ts\",\n", " \"ק\": \"k\",\n", " \"ר\": \"r\",\n", " \"ש\": \"sh\",\n", " \"ת\": \"t\",\n", " \"ן\": \"n\",\n", " \"ם\": \"m\",\n", " \"ף\": \"f\",\n", " \"ץ\": \"ts\",\n", " \"ך\": \"h\",\n", " }\n", "\n", " patah_ganav={\n", " \"חַ\": \"ah\",\n", " \"חָ\": \"ah\",\n", " \"הַ\": \"hha\",\n", " \"הָ\": \"hha\",\n", " \"עַ\": \"a\",\n", " \"עָ\": \"a\",\n", "\n", " }\n", "\n", " tzuptzik_letters={\n", " ##G\n", " \"ג\": \"j\",\n", " \"גְ\": \"j\",\n", " \"גִ\": \"ji\",\n", " \"גֹ\": \"jo\",\n", " \"גֵ\": \"je\",\n", " \"גֶ\": \"je\",\n", " \"גַ\": \"ja\",\n", " \"גָ\": \"ja\",\n", " \"גֻ\": \"joo\",\n", " \"גּ\": \"j\",\n", " \"גְּ\": \"j\",\n", " \"גִּ\": \"ji\",\n", " \"גֹּ\": \"jo\",\n", " \"גֵּ\": \"je\",\n", " \"גֶּ\": \"je\",\n", " \"גַּ\": \"ja\",\n", " \"גָּ\": \"ja\",\n", " \"גֻּ\": \"joo\",\n", "\n", " ##ch\n", " \"צ\": \"ch\",\n", " \"צְ\": \"ch\",\n", " \"צִ\": \"chi\",\n", " \"צֹ\": \"cho\",\n", " \"צֵ\": \"che\",\n", " \"צֶ\": \"che\",\n", " \"צַ\": \"cha\",\n", " \"צָ\": \"cha\",\n", " \"צֻ\": \"choo\",\n", "\n", " ##ch\n", " \"ץ\": \"ch\",\n", " \"ץְ\": \"ch\",\n", " \"ץִ\": \"chi\",\n", " \"ץֹ\": \"cho\",\n", " \"ץֵ\": \"che\",\n", " \"ץֶ\": \"che\",\n", " \"ץַ\": \"cha\",\n", " \"ץָ\": \"cha\",\n", " \"ץֻ\": \"choo\",\n", "\n", " ##Z\n", " \"ז\": \"zh\",\n", " \"זְ\": \"zh\",\n", " \"זִ\": \"zhi\",\n", " \"זֹ\": \"zho\",\n", " \"זֵ\": \"zhe\",\n", " \"זֶ\": \"zhe\",\n", " \"זַ\": \"zha\",\n", " \"זָ\": \"zha\",\n", " \"זֻ\": \"zhoo\",\n", " }\n", "\n", " if last_letter:\n", " if obj in patah_ganav:\n", " return patah_ganav[obj]\n", "\n", " if tzuptzik==True:\n", " if obj in tzuptzik_letters:\n", " return tzuptzik_letters[obj]\n", "\n", " if obj in beged_kefet_shin_sin:\n", " return beged_kefet_shin_sin[obj]\n", " elif obj in vav:\n", " return vav[obj]\n", " else:\n", " lst = break_to_list(obj)\n", " string = \"\"\n", " for item in lst:\n", " if item in letters_map:\n", " string += letters_map[item]\n", " if item in nikud_map:\n", " string += nikud_map[item]\n", "\n", " return string\n", "\n", "\n", "##takes hebrew word and turns it into the sound in english\n", "def HebrewWordToEnglishSound(word,index):\n", " new_sentence=\"\"\n", " hs = Hebrew(word)\n", " hs = Hebrew(list(hs.graphemes)).string\n", " for i, letter in enumerate(hs):\n", "\n", " tzuptzik = False\n", " if i < len(hs) - 1:\n", " if hs[i + 1] == '\\'':\n", " tzuptzik = True\n", "\n", " tav = HebrewLetterToEnglishSound(letter, tzuptzik, i == len(hs) - 1)\n", " new_sentence += tav\n", "\n", " ##clean list:\n", " try:\n", " if new_sentence[-1] == 'y' and new_sentence[-2] == 'y':\n", " new_sentence = new_sentence.replace(\"yy\", \"y\")\n", " except:\n", " pass\n", " return new_sentence\n", "\n", "##takes hebrew sentence and turns it into english sounds\n", "def ARPA(sentence,index=0):\n", " words = sentence.split()\n", " new_sentence = \"\"\n", "\n", " for word in words:\n", " ##if number not in string\n", " if not has_number(word):\n", "\n", " ##breaks the word to letters and ',' and '.'\n", " broken_word=break_to_letter_and_rebuild(word)\n", "\n", " for brk_word in broken_word:\n", "\n", " ##tries to add silence\n", " if brk_word=='.' or brk_word==',' or brk_word==';':\n", " new_sentence += \"q\"+\" \"\n", "\n", " else:\n", " ret_sentence=HebrewWordToEnglishSound(brk_word,index)\n", " new_sentence+=ret_sentence+\" \"\n", "\n", " ##if there is a number:\n", " else:\n", " try:\n", " before_num,num,after_num=split_number_and_string(word)\n", "\n", " if has_number(after_num) or has_number(before_num):\n", " list_of_numbers=clean_number(word)\n", " for number in list_of_numbers:\n", " ret_sentence = HebrewWordToEnglishSound(number, index)\n", " new_sentence += ret_sentence + \" \"\n", "\n", " else:\n", " ret_sentence = HebrewWordToEnglishSound(before_num, index)\n", " new_sentence += ret_sentence+\" \"\n", "\n", " num = [s for s in word if s.isdigit()]\n", " num=\"\".join(num)\n", " num=int(num)\n", " list_of_numbers=NumberToHebrew(num)\n", " for number in list_of_numbers:\n", " ret_sentence=HebrewWordToEnglishSound(number,index)\n", " new_sentence += ret_sentence + \" \"\n", "\n", " ret_sentence = HebrewWordToEnglishSound(after_num, index)\n", " new_sentence += ret_sentence + \" \"\n", "\n", "\n", "\n", " except:\n", " print(\"error from split_number_and_string in line:\", index,\"with word: \",word)\n", "\n", "\n", "\n", " return new_sentence\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "torch.set_grad_enabled(False)\n", "\n", "# initialize Tacotron2 with the pretrained model\n", "hparams = create_hparams()" ] }, { "cell_type": "markdown", "metadata": { "id": "Kz_IVZfZbJob" }, "source": [ "Load Tacotron2 (run this cell every time you change the model)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "FCyv8MmOvla7", "outputId": "ade64e2d-42ac-4f2d-a4ec-d0955eb8f43b" }, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ ":6: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", " model.load_state_dict(torch.load(tacotron2_pretrained_model)['state_dict'])\n" ] } ], "source": [ "# Load Tacotron2 (run this cell every time you change the model)\n", "hparams.sampling_rate = 22050 # Don't change this\n", "hparams.max_decoder_steps = 1800 # How long the audio will be before it cuts off (1000 is about 11 seconds)\n", "hparams.gate_threshold = 0.1 # Model must be 90% sure the clip is over before ending generation (the higher this number is, the more likely that the AI will keep generating until it reaches the Max Decoder Steps)\n", "model = Tacotron2(hparams)\n", "model.load_state_dict(torch.load(tacotron2_pretrained_model)['state_dict'])\n", "_ = model.cuda().eval()" ] }, { "cell_type": "markdown", "metadata": { "id": "IiEW9zGhbGg6" }, "source": [ "###Load WaveGlow" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "QnW74wETvoIS", "outputId": "3f72d433-9f2e-44b4-e540-43193e081f86" }, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ ":2: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", " waveglow = torch.load(waveglow_pretrained_model)['model']\n", "/content/tacotron2/waveglow/glow.py:265: UserWarning: The torch.cuda.*DtypeTensor constructors are no longer recommended. It's best to use methods such as torch.tensor(data, dtype=*, device='cuda') to create tensors. (Triggered internally at ../torch/csrc/tensor/python_tensor.cpp:78.)\n", " audio = torch.cuda.FloatTensor(spect.size(0),\n" ] } ], "source": [ "# Load WaveGlow\n", "waveglow = torch.load(waveglow_pretrained_model)['model']\n", "waveglow.cuda().eval()\n", "for k in waveglow.convinv:\n", " k.float()\n", "denoiser = Denoiser(waveglow)" ] }, { "cell_type": "markdown", "metadata": { "id": "CBDBF0Oxa-H0" }, "source": [ "# Here you can input the text:\n", "you must include .(dot) in the end of the line\n", "\n", "For example view the text_example in the box below." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Hj1wOkKJao_j" }, "outputs": [], "source": [ " #This is the text that will be created as audio, feel free to change it\n", "#text_example = \"אַתֶּם הֶאֱזַנְתֶּם לְחַיוֹת כִּיס, הַפּוֹדְקָאסְט הַכַּלְכָּלִי שֶׁל כָּאן.\"\n", "text = \"וַאֲנַחְנוּ נִבְדּוֹק הַאִם אַתֶּם וְאֶתֶּן שַׂמְתֶּם לֵב. כָּכָה אֲנִי מְדַמְיֵין אֶת הֶעָתִיד שֶׁלִּי מַגְנִיב וְגַם מַקְרִיפּ\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 127 }, "id": "B5Zb4w8bvog5", "outputId": "4288b18a-7593-406e-fb9e-717ba53ff387" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "וַאֲנַחְנוּ נִבְדּוֹק הַאִם אַתֶּם וְאֶתֶּן שַׂמְתֶּם לֵב. כָּכָה אֲנִי מְדַמְיֵין אֶת הֶעָתִיד שֶׁלִּי מַגְנִיב וְגַם מַקְרִיפּ\n", "vaanahnoo nivdok hhaim atem veeten samtem lev q kahahh aniy mdamyeyn et hheatiyd sheliy magniyv vegam makriyp \n", "\n" ] }, { "output_type": "display_data", "data": { "text/plain": [ "" ], "text/html": [ "\n", " \n", " " ] }, "metadata": {} } ], "source": [ "sigma = 0.75\n", "denoise_strength = 0.2\n", "# try to switch raw data to True maybe the results will be better\n", "raw_input = False # disables automatic ARPAbet conversion, useful for inputting your own ARPAbet pronounciations or just for testing\n", "\n", "for i in text.split(\"\\n\"):\n", " if len(i) < 1: continue;\n", " print(i)\n", " if raw_input:\n", " if i[-1] != \";\": i=i+\";\"\n", " else: i = ARPA(i)\n", " print(i)\n", " with torch.no_grad(): # save VRAM by not including gradients\n", " sequence = np.array(text_to_sequence(i, ['english_cleaners']))[None, :]\n", " sequence = torch.autograd.Variable(torch.from_numpy(sequence)).cuda().long()\n", " mel_outputs, mel_outputs_postnet, _, alignments = model.inference(sequence)\n", " # plot_data((mel_outputs_postnet.float().data.cpu().numpy()[0],alignments.float().data.cpu().numpy()[0].T))\n", " audio = waveglow.infer(mel_outputs_postnet, sigma=sigma); print(\"\"); ipd.display(ipd.Audio(audio[0].data.cpu().numpy(), rate=hparams.sampling_rate))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "qAbYMs3CG8uZ" }, "outputs": [], "source": [] } ], "metadata": { "accelerator": "GPU", "colab": { "gpuType": "T4", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 }