{"id":2083,"date":"2023-01-18T21:06:00","date_gmt":"2023-01-18T20:06:00","guid":{"rendered":"https:\/\/theroamingworkshop.cloud\/b\/?p=2083"},"modified":"2023-11-19T15:29:25","modified_gmt":"2023-11-19T14:29:25","slug":"%f0%9f%90%a2tortoise-tts-ai-text-to-speech-generation","status":"publish","type":"post","link":"https:\/\/theroamingworkshop.cloud\/b\/en\/2083\/%f0%9f%90%a2tortoise-tts-ai-text-to-speech-generation\/","title":{"rendered":"\ud83d\udc22TorToiSe-TTS: AI text to speech generation"},"content":{"rendered":"\n<p>AI trends are here to stay, and today there&#8217;s much talk about <strong>Vall-E<\/strong> and its future combination with GPT-3. But we must remember that all these Artificial Intelligence products come from collaborative investigation that have been freely available, so we will always find an open-source equivalent, and we must be thankful about it.<\/p>\n\n\n\n<p>That&#8217;s the case of <strong>TorToiSe-TTS<\/strong> (text to speech), an AI voice generator from written text totally free to use in your PC.<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/neonbjb\/tortoise-tts\" target=\"_blank\">https:\/\/github.com\/neonbjb\/tortoise-tts<\/a><\/p>\n\n\n\n<p>Just listen to a little sample below from <strong>Morgan Freeman<\/strong>:<\/p>\n\n\n\n<iframe style=\"border:0;width:100%;height:250px\" src=\"https:\/\/theroamingworkshop.cloud\/aM\/freeman.php\"><\/iframe>\n\n\n\n<div id=\"menu\" style=\"padding:20px 20px 20px 20px; border-left:2px solid darkgrey;\">\n<p style=\"font-weight:bold;\">Content<\/p>\n<\/div>\n<script>\nvar text;\nvar element;\n\nfunction fillmenu(){\n\nfor (let i=0; i<window.document.getElementsByTagName(\"h2\").length; i++){\nelement = window.document.getElementsByTagName(\"h2\")[i];\ntext = \"\u25b9 \"+element.innerHTML;\nvar newelement = document.createElement(\"a\");\nnewelement.innerHTML=text;\nvar postid=window.document.getElementsByTagName(\"article\")[0].id;\nvar url = \"https:\/\/theroamingworkshop.cloud\/b\/?p=\"+postid.substr(5,postid.length)+\"#\"+element.id;\nnewelement.setAttribute(\"href\", url);\nnewelement.appendChild(document.createElement(\"br\"));\nwindow.document.getElementById(\"menu\").appendChild(newelement);\nconsole.log(text);\n}\n}\nif(window.location.href.includes(\"tag\")){\n\n}else{\nwindow.setTimeout(fillmenu,2000);\n}\n\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation\">Installation<\/h2>\n\n\n\n<p>The easiest is to use the cloud script in <strong>Google Collab<\/strong> uploaded by the developer:<\/p>\n\n\n\n<p><a href=\"https:\/\/colab.research.google.com\/drive\/1wVVqUPqwiDBUVeWWOUNglpGhU3hg_cbR?usp=sharing\">https:\/\/colab.research.google.com\/drive\/1wVVqUPqwiDBUVeWWOUNglpGhU3hg_cbR?usp=sharing<\/a><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts3.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"435\" src=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts3-1024x435.png\" alt=\"\" class=\"wp-image-2068\" srcset=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts3-1024x435.png 1024w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts3-300x127.png 300w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts3-768x326.png 768w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts3-676x287.png 676w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts3.png 1125w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>You just need to sign in and click \"play\" \u25b6 to run each block of code.<\/p>\n\n\n\n<p>But for sure you want to run TorToiSe-TTS locally, without internet, and save the audio in your local drive, so let's move on.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-python3\">Installing python3<\/h3>\n\n\n\n<p>Like many AI applications, TorToiSe-TTS runs in python, so you need <strong>python3<\/strong> in your PC. I always recommend the use of Linux, but you might be able to run it in a Windows terminal as well.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.python.org\/downloads\/<\/a><\/p>\n\n\n\n<p>On Linux, just install it from your distro repo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get update\nsudo apt-get install python3.11<\/code><\/pre>\n\n\n\n<p>You'll also need the module <strong>venv<\/strong> to virtualize a python environment (it uses to come with the Windows installer):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install python3.11-venv<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"download-repository\">Download repository<\/h3>\n\n\n\n<p>Download the official repository:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/neonbjb\/tortoise-tts\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/neonbjb\/tortoise-tts<\/a><\/p>\n\n\n\n<p>Be it the compressed file:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts1.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"450\" src=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts1-1024x450.png\" alt=\"\" class=\"wp-image-2067\" srcset=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts1-1024x450.png 1024w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts1-300x132.png 300w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts1-768x338.png 768w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts1-676x297.png 676w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts1.png 1240w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Or using <strong>git<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/neonbjb\/tortoise-tts<\/code><\/pre>\n\n\n\n<p>You can also download my fork repository, where I add further installation instructions, a terminal automatic launcher and some test voices for Ultron (yes, Tony Stark's evil droid) which we'll see later on.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/TheRoam\/tortoise-tts-linuxLauncher\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/TheRoam\/tortoise-tts-linuxLauncher<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"create-a-python-virtual-environment\">Create a python virtual environment<\/h3>\n\n\n\n<p>Next we'll have to install a series of python modules needed to run TorToiSe-TTS, but before this, we'll create a virtual python version, so the installation of these modules won't affect the rest of the python installation. You'll find this helpful when you use different AI apps that use different versions of the same module.<\/p>\n\n\n\n<p>Open a terminal and write the following, so you'll create a \"TTS\" environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd tortoise-tts\npython3 -m venv TTS<\/code><\/pre>\n\n\n\n<p>Activate it this way:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source TTS\/bin\/activate<\/code><\/pre>\n\n\n\n<p>And now you'll see a referente to the TTS environment in the terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(TTS) abc@123:~$ |<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-python-modules\">Install python modules<\/h3>\n\n\n\n<p>Let's now install the required modules, following the collab indications:<\/p>\n\n\n\n<p><a href=\"https:\/\/colab.research.google.com\/drive\/1wVVqUPqwiDBUVeWWOUNglpGhU3hg_cbR?usp=sharing#scrollTo=Gen09NM4hONQ\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/colab.research.google.com\/drive\/1wVVqUPqwiDBUVeWWOUNglpGhU3hg_cbR?usp=sharing#scrollTo=Gen09NM4hONQ<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install -U scipy\npip3 install transformers==4.19.0\npip3 install -r requirements.txt\npython3 setup.py install<\/code><\/pre>\n\n\n\n<p>Now you can try running TorToiSe-TTS, but some libraries will fail, depending on your python installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 scripts\/tortoise_tts.py \"This is The Roaming Workshop\" -v \"daniel\" -p \"fast\" -o \"test1.wav\"<\/code><\/pre>\n\n\n\n<p>Try the previous command until you don't get any errors, installing the missing moules. In my case, they were the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install torch\npip3 install torchaudio\npip3 install llvmlite\npip3 install numpy==1.23<\/code><\/pre>\n\n\n\n<p>Finally, this <strong>test1.wav<\/strong> sound like this in the voice of <strong>daniel<\/strong> (which turns out to be <strong>Daniel Craig<\/strong>):<\/p>\n\n\n\n<iframe style=\"border:0;width:100%;height:250px\" src=\"https:\/\/theroamingworkshop.cloud\/aM\/daniel.php\"><\/iframe>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-TorToiSe-TTS\">Using TorToiSe-TTS<\/h2>\n\n\n\n<p>The most simple program in <strong>TorToiSe-TTS<\/strong> is found in the folder  <code>scripts\/tortoise_tts.py<\/code> and these are the main arguments:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 scripts\/tortoise_tts.py \"text\" -v \"voice\" -V \"route\/to\/voices\/folder\" --seed number -p \"fast\" -o \"output-file.wav\" <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\"text\"<\/code>: text chain that will be converted to audio<\/li>\n\n\n\n<li><code>-v<\/code>: voice to be used to convert text. It must be the name of one of the folders available in <code>\/tortoise\/voices\/<\/code><\/li>\n\n\n\n<li><code>-V<\/code>: specifies a folder for voices, in the case that you use a custom one.<\/li>\n\n\n\n<li><code>--seed<\/code>: seed number to feature the algorithm (can be any number)<\/li>\n\n\n\n<li><code>-p<\/code>: preset mode that determines quality (\"ultra_fast\", \"fast\", \"standard\", \"high_quality\").<\/li>\n\n\n\n<li><code>-o<\/code>: route and name of the output file. You must specify the fileformat, which is <code>.wav<\/code><\/li>\n<\/ul>\n\n\n\n<p>If you use my repo script <code>TTS.sh<\/code> you'll be asked for these arguments on screen and it will run the algorithm automatically.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts4.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"947\" height=\"608\" src=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts4.png\" alt=\"\" class=\"wp-image-2070\" srcset=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts4.png 947w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts4-300x193.png 300w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts4-768x493.png 768w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts4-676x434.png 676w\" sizes=\"auto, (max-width: 947px) 100vw, 947px\" \/><\/a><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"add-your-own-voices\">Add your own voices<\/h2>\n\n\n\n<p>You can add more voices to TorToiSe-TTS. For example, I wanted to add the voice of Ultron, the Marvel supervillain, following the developer <strong>Neonbjb<\/strong> indications:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You must record <strong>3 \"clean\" samples<\/strong> (without background noise or music) of about <strong>10 seconds<\/strong> duration.<\/li>\n\n\n\n<li>The format must be <strong>16bits floating point WAV<\/strong> with <strong>22500<\/strong> sample rate (you can use <strong>Audacity<\/strong>)<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"542\" src=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5-1024x542.png\" alt=\"\" class=\"wp-image-2072\" srcset=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5-1024x542.png 1024w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5-300x159.png 300w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5-768x407.png 768w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5-1536x814.png 1536w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5-676x358.png 676w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/tts5.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Create a new folder inside <code>\/tortoise\/voices<\/code> (or anywhere, really) and save your recordings there.<\/li>\n\n\n\n<li>When running TorToiSe-TTS, you'll need to call the voices folder with argument <code>-V<\/code> and the new voice with argument <code>-v<\/code><\/li>\n<\/ul>\n\n\n\n<p>For example, to use my Ultron recordings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 sripts\/tortoise_tts.py \"This is The Roaming Workshop\" -V \".\/tortoise\/voices\" -v \"ultron-en\" -p \"fast\" --seed 17 -o \".\/wavs\/TRW_ultron3.wav\"<\/code><\/pre>\n\n\n\n<p>Which sound like this:<\/p>\n\n\n\n<iframe style=\"border:0;width:100%;height:250px\" src=\"https:\/\/theroamingworkshop.cloud\/aM\/ultron.php\"><\/iframe>\n\n\n\n<p>I've taken cuts from a scene in <em>Avengers: age of Ultron<\/em>, both in English (<strong>ultron-en<\/strong>) and Spanish (<strong>ultron-es<\/strong>) which you can download from my repository.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1280\" src=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited.png\" alt=\"\" class=\"wp-image-2075\" srcset=\"https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited.png 2048w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited-300x188.png 300w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited-1024x640.png 1024w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited-768x480.png 768w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited-1536x960.png 1536w, https:\/\/theroamingworkshop.cloud\/b\/wp-content\/uploads\/2023\/01\/Ultron_supervillain_close_shot_with_blurry_background_16-edited-676x423.png 676w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><figcaption class=\"wp-element-caption\">\"Ultron supervillain\" by Optimised Stable Diffusion + Upscayl 2. The Roaming Workshop 2023.<\/figcaption><\/figure>\n<\/div>\n\n\n<p>Right now, the TorToiSe-TTS model is <strong>trained only in English<\/strong>, so it only woks properly in this language.<\/p>\n\n\n\n<p>You can introduce text in another language, and AI will <strong>try to read it<\/strong>, but it will use the pronunciation learnt in English and it will sound weird.<\/p>\n\n\n\n<p>If you are willing to train a model in your language (you need plenty GPU and several months), contact the developer, as he's keep to expand the project.<\/p>\n\n\n\n<p>In the meantime, you can send any doubts or comments on \ud83d\udc26 Twitter or \ud83d\udc24 Koo!<\/p>\n\n\n\n<p>\ud83d\udc26 <code><a rel=\"noreferrer noopener\" href=\"https:\/\/twitter.com\/roamingworkshop\" target=\"_blank\">@RoamingWorkshop<\/a><\/code><\/p>\n\n\n\n<p>\ud83d\udc24 <a rel=\"noreferrer noopener\" href=\"https:\/\/www.kooapp.com\/profile\/TheRoamingWorkshop\" target=\"_blank\">@TheRoamingWorkshop<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AI trends are here to stay, and today there&#8217;s much talk about Vall-E and its future combination with GPT-3. But we must remember that all these Artificial Intelligence products come from collaborative investigation that have been freely available, so we will always find an open-source equivalent, and we must be thankful about it. That&#8217;s the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2069,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[592,44],"tags":[339,341,343,345,347,349,351,353,355,357],"class_list":["post-2083","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-software","tag-ai-en","tag-artifitial-intelligence-en","tag-ia-en","tag-inteligencia-artificial-en","tag-text-to-speech-en","tag-texto-a-voz-en","tag-tortoise-en","tag-tts-en","tag-voces-en","tag-voices-en","post-preview"],"_links":{"self":[{"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/posts\/2083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/comments?post=2083"}],"version-history":[{"count":4,"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/posts\/2083\/revisions"}],"predecessor-version":[{"id":2092,"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/posts\/2083\/revisions\/2092"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/media\/2069"}],"wp:attachment":[{"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/media?parent=2083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/categories?post=2083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroamingworkshop.cloud\/b\/wp-json\/wp\/v2\/tags?post=2083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}