Advertisement
Guest User

Untitled

a guest
Sep 4th, 2022
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.38 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {
  6. "id": "m_HkOd4jwqIb"
  7. },
  8. "source": [
  9. "Connect Google drive account"
  10. ]
  11. },
  12. {
  13. "cell_type": "code",
  14. "execution_count": null,
  15. "metadata": {
  16. "id": "-RUb7_iJu1mb"
  17. },
  18. "outputs": [],
  19. "source": [
  20. "from google.colab import drive\n",
  21. "\n",
  22. "drive.mount(\"/content/drive\")"
  23. ]
  24. },
  25. {
  26. "cell_type": "markdown",
  27. "metadata": {
  28. "id": "WIvwEf9zydzN"
  29. },
  30. "source": [
  31. "Download and Build Rnnoise and Requirements"
  32. ]
  33. },
  34. {
  35. "cell_type": "code",
  36. "execution_count": null,
  37. "metadata": {
  38. "id": "1HigwgxZxEXf"
  39. },
  40. "outputs": [],
  41. "source": [
  42. "!pip install pyloudnorm\n",
  43. "!git clone https://github.com/xiph/rnnoise.git\n",
  44. "!sudo apt-get install curl autoconf automake libtool python-dev pkg-config sox\n",
  45. "%cd /content/rnnoise\n",
  46. "!sh autogen.sh\n",
  47. "!sh configure\n",
  48. "!make clean\n",
  49. "!make"
  50. ]
  51. },
  52. {
  53. "cell_type": "code",
  54. "execution_count": null,
  55. "metadata": {
  56. "colab": {
  57. "base_uri": "https://localhost:8080/"
  58. },
  59. "id": "Lyz3RjlYuXjz",
  60. "outputId": "effb28bd-2b59-4ddc-e391-52f534a35e54"
  61. },
  62. "outputs": [
  63. {
  64. "name": "stdout",
  65. "output_type": "stream",
  66. "text": [
  67. "usage: /content/rnnoise/examples/.libs/rnnoise_demo <noisy speech> <output denoised>\n"
  68. ]
  69. }
  70. ],
  71. "source": [
  72. ""
  73. ]
  74. },
  75. {
  76. "cell_type": "markdown",
  77. "metadata": {
  78. "id": "vWzQveIIy7QW"
  79. },
  80. "source": [
  81. "Install Coqui TTS"
  82. ]
  83. },
  84. {
  85. "cell_type": "code",
  86. "execution_count": null,
  87. "metadata": {
  88. "id": "jyCWXW_2y_nx"
  89. },
  90. "outputs": [],
  91. "source": [
  92. "!sudo apt-get install espeak-ng\n",
  93. "!git clone https://github.com/coqui-ai/TTS.git\n",
  94. "%cd /content/TTS\n",
  95. "!pip install numpy==1.21.6\n",
  96. "!pip install black\n",
  97. "!pip install coverage\n",
  98. "!pip install isort\n",
  99. "!pip install nose\n",
  100. "!pip install pylint==2.10.2\n",
  101. "!pip install bokeh==1.4.0\n",
  102. "# core deps\n",
  103. "#!pip install numpy==1.19.5\n",
  104. "!pip install cython\n",
  105. "!pip install scipy>=1.4.0\n",
  106. "!pip install torch>=1.7\n",
  107. "!pip install torchaudio\n",
  108. "!pip install soundfile\n",
  109. "!pip install librosa==0.8.0\n",
  110. "!pip install numba==0.53\n",
  111. "!pip install inflect\n",
  112. "!pip install tqdm\n",
  113. "!pip install anyascii\n",
  114. "!pip install pyyaml\n",
  115. "!pip install fsspec>=2021.04.0\n",
  116. "# deps for examples\n",
  117. "!pip install flask\n",
  118. "# deps for inference\n",
  119. "!pip install pysbd\n",
  120. "# deps for notebooks\n",
  121. "!pip install umap-learn==0.5.1\n",
  122. "!pip install pandas\n",
  123. "# deps for training\n",
  124. "!pip install matplotlib\n",
  125. "!pip install tensorboardX\n",
  126. "!pip install pyworld\n",
  127. "# coqui stack\n",
  128. "!pip install trainer\n",
  129. "!pip install coqpit # config management\n",
  130. "# chinese g2p deps\n",
  131. "!pip install jieba\n",
  132. "!pip install pypinyin\n",
  133. "# japanese g2p deps\n",
  134. "!pip install mecab-python3==1.0.3\n",
  135. "!pip install unidic-lite==1.0.8\n",
  136. "# gruut+supported langs\n",
  137. "!pip install gruut[cs,de,es,fr,it,nl,pt,ru,sv]==2.2.3\n",
  138. "!pip install tf-estimator-nightly==2.8.0.dev2021122109\n",
  139. "#!pip install bokeh==2.3.0\n",
  140. "!pip install tensorflow==2.8.0\n",
  141. "!pip install panel==0.12.1\n",
  142. "!pip install folium==0.2.1\n",
  143. "!pip install datascience==0.10.6\n",
  144. "!pip install imgaug==0.2.6\n",
  145. "!pip install albumentations==0.1.12\n",
  146. "!pip install -e .[all,dev,notebooks] # Select the relevant extras\n",
  147. "!make system-deps\n",
  148. "!make install\n",
  149. "!pip install numpy==1.21.6\n",
  150. "!pip install TTS\n",
  151. "!tts --list_models"
  152. ]
  153. },
  154. {
  155. "cell_type": "markdown",
  156. "metadata": {
  157. "id": "EX5ftK4TzPUD"
  158. },
  159. "source": [
  160. "Download VITS model and Generate Sample Wav File"
  161. ]
  162. },
  163. {
  164. "cell_type": "code",
  165. "execution_count": null,
  166. "metadata": {
  167. "id": "Vy-BadvazVNM"
  168. },
  169. "outputs": [],
  170. "source": [
  171. "!tts --text \"I am the very model of a modern Major General\" --model_name \"tts_models/en/ljspeech/vits\" --out_path /content/drive/MyDrive/speech_out/ljspeech-vits.wav"
  172. ]
  173. },
  174. {
  175. "cell_type": "markdown",
  176. "metadata": {
  177. "id": "uSthp75hzZvz"
  178. },
  179. "source": [
  180. "Process Audio Clips"
  181. ]
  182. },
  183. {
  184. "cell_type": "code",
  185. "execution_count": null,
  186. "metadata": {
  187. "id": "xyV6G0mozcdk"
  188. },
  189. "outputs": [],
  190. "source": [
  191. "!python /content/drive/MyDrive/rnnoise.py /content/drive/MyDrive/original"
  192. ]
  193. },
  194. {
  195. "cell_type": "markdown",
  196. "metadata": {
  197. "id": "XS08OyEVzeJA"
  198. },
  199. "source": [
  200. "Fine Tune VITS model"
  201. ]
  202. },
  203. {
  204. "cell_type": "code",
  205. "execution_count": null,
  206. "metadata": {
  207. "colab": {
  208. "background_save": true
  209. },
  210. "id": "DviNKw7rzkyK"
  211. },
  212. "outputs": [],
  213. "source": [
  214. "!CUDA_VISIBLE_DEVICES=\"0\" python /content/drive/MyDrive/train-vits-bg-colab.py --restore_path /root/.local/share/tts/tts_models--en--ljspeech--vits/model_file.pth"
  215. ]
  216. },
  217. {
  218. "cell_type": "markdown",
  219. "metadata": {
  220. "id": "uRa5mrGRlRc9"
  221. },
  222. "source": [
  223. "Generate Speech using Your Fined Tuned Model. Point the model_path to the checkpoint.pth file and the config_path to the config.json from the trainer output."
  224. ]
  225. },
  226. {
  227. "cell_type": "code",
  228. "execution_count": null,
  229. "metadata": {
  230. "id": "BICjNNGulR2M"
  231. },
  232. "outputs": [],
  233. "source": [
  234. "!tts --text \"I am the very model of a modern Major General\" --config_path \"/content/drive/MyDrive/DIRECTORY/config.json\" --model_path \"/content/drive/MyDrive/DIRECTORY/MODELFILENAME.pth\" --out_path /content/drive/MyDrive/speech_out/words-vits.wav"
  235. ]
  236. },
  237. {
  238. "cell_type": "markdown",
  239. "metadata": {
  240. "id": "IH0v8dCfng9U"
  241. },
  242. "source": [
  243. "Continue Training Run. \n",
  244. "Edit the path to reflect the training output from a previous run."
  245. ]
  246. },
  247. {
  248. "cell_type": "code",
  249. "execution_count": null,
  250. "metadata": {
  251. "id": "PiM4XGXgnnIc"
  252. },
  253. "outputs": [],
  254. "source": [
  255. "!CUDA_VISIBLE_DEVICES=\"0\" python /content/drive/MyDrive/train-vits-bg-colab.py --restore_path /content/drive/MyDrive/DATASET-DIRECTORY/traineroutput/TRAINING_RUN/CHECKPOINTFILE.pth --config_path /content/drive/MyDrive/DATASET-DIRECTORY/traineroutput/TRAINING_RUN/config.json"
  256. ]
  257. },
  258. {
  259. "cell_type": "markdown",
  260. "metadata": {
  261. "id": "UZ2WoSCqzqxH"
  262. },
  263. "source": [
  264. "View Memory Usage"
  265. ]
  266. },
  267. {
  268. "cell_type": "code",
  269. "execution_count": null,
  270. "metadata": {
  271. "id": "ryma4sViztPk"
  272. },
  273. "outputs": [],
  274. "source": [
  275. "!nvidia-smi"
  276. ]
  277. },
  278. {
  279. "cell_type": "markdown",
  280. "metadata": {
  281. "id": "-ORJUVXnz4B5"
  282. },
  283. "source": [
  284. "Load Tensorboard"
  285. ]
  286. },
  287. {
  288. "cell_type": "code",
  289. "execution_count": null,
  290. "metadata": {
  291. "id": "J1gPy_jSz551"
  292. },
  293. "outputs": [],
  294. "source": [
  295. "import torch \n",
  296. "with torch.no_grad():\n",
  297. " torch.cuda.empty_cache()\n",
  298. "from __future__ import absolute_import, division, print_function, unicode_literals\n",
  299. "\n",
  300. "try:\n",
  301. " # %tensorflow_version only exists in Colab.\n",
  302. " %tensorflow_version 2.x\n",
  303. "except Exception:\n",
  304. " pass\n",
  305. " \n",
  306. "# Load the TensorBoard notebook extension\n",
  307. "%load_ext tensorboard"
  308. ]
  309. },
  310. {
  311. "cell_type": "markdown",
  312. "metadata": {
  313. "id": "hkt32dP3z9sK"
  314. },
  315. "source": [
  316. "Load Dashboard"
  317. ]
  318. },
  319. {
  320. "cell_type": "code",
  321. "execution_count": null,
  322. "metadata": {
  323. "id": "PxPBHCGf0AVt"
  324. },
  325. "outputs": [],
  326. "source": [
  327. "%tensorboard --logdir /content/drive/MyDrive/bg-dataset/traineroutput/"
  328. ]
  329. }
  330. ],
  331. "metadata": {
  332. "accelerator": "GPU",
  333. "colab": {
  334. "collapsed_sections": [],
  335. "name": "Voice Clone.ipynb",
  336. "provenance": []
  337. },
  338. "gpuClass": "standard",
  339. "kernelspec": {
  340. "display_name": "Python 3",
  341. "name": "python3"
  342. },
  343. "language_info": {
  344. "name": "python"
  345. }
  346. },
  347. "nbformat": 4,
  348. "nbformat_minor": 0
  349. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement