readme: # TorToiSe
  
  Tortoise is a text-to-speech program built with the following priorities:
  
  1. Strong multi-voice capabilities.
  2. Highly realistic prosody and intonation.
  
  This repo contains all the code needed to run Tortoise TTS in inference mode.
  
  ### New features
  
  #### v2.1; 2022/5/2
  - Added ability to produce totally random voices.
  - Added ability to download voice conditioning latent via a script, and then use a user-provided conditioning latent.
  - Added ability to use your own pretrained models.
  - Refactored directory structures.
  - Performance improvements & bug fixes.
  
  ## What's in a name?
  
  I'm naming my speech-related repos after Mojave desert flora and fauna. Tortoise is a bit tongue in cheek: this model
  is insanely slow. It leverages both an autoregressive decoder **and** a diffusion decoder; both known for their low
  sampling rates. On a K80, expect to generate a medium sized sentence every 2 minutes.
  
  ## Demos
  
  See [this page](http://nonint.com/static/tortoise_v2_examples.html) for a large list of example outputs.
  
  ## Usage guide
  
  ### Colab
  
  Colab is the easiest way to try this out. I've put together a notebook you can use here:
  https://colab.research.google.com/drive/1wVVqUPqwiDBUVeWWOUNglpGhU3hg_cbR?usp=sharing
  
  ### Installation
  
  If you want to use this on your own computer, you must have an NVIDIA GPU. First, install pytorch using these
  instructions: [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
  
  Then:
  
  ```shell
  git clone https://github.com/neonbjb/tortoise-tts.git
  cd tortoise-tts
  python setup.py install
  ```
  
  ### do_tts.py
  
  This script allows you to speak a single phrase with one or more voices.
  ```shell
  python tortoise/do_tts.py --text "I'm going to speak this" --voice random --preset fast
  ```
  
  ### read.py
  
  This script provides tools for reading large amounts of text.
  
  ```shell
  python tortoise/read.py --textfile <your text to be read> --voice random
  ```
  
  This will break up the textfile into sentences, and then convert them to speech one at a time. It will output a series 
  of spoken clips as they are generated. Once all the clips are generated, it will combine them into a single file and
  output that as well.
  
  Sometimes Tortoise screws up an output. You can re-generate any bad clips by re-running `read.py` with the --regenerate
  argument.
  
  ### API
  
  Tortoise can be used programmatically, like so:
  
  ```python
  reference_clips = [utils.audio.load_audio(p, 22050) for p in clips_paths]
  tts = api.TextToSpeech()
  pcm_audio = tts.tts_with_preset("your text here", reference_clips, preset='fast')
  ```
  
  ## Voice customization guide
  
  Tortoise was specifically trained to be a multi-speaker model. It accomplishes this by consulting reference clips.
  
  These reference clips are recordings of a speaker that you provide to guide speech generation. These clips are used to determine many properties of the output, such as the pitch and tone of the voice, speaking speed, and even speaking defects like a lisp or stuttering. The reference clip is also used to determine non-voice related aspects of the audio output like volume, background noise, recording quality and reverb.
  
  ### Random voice
  
  I've included a feature which randomly generates a voice. These voices don't actually exist and will be random every time you run 
  it. The results are quite fascinating and I recommend you play around with it!
  
  You can use the random voice by passing in 'random' as the voice name. Tortoise will take care of the rest.
  
  For the those in the ML space: this is created by projecting a random vector onto the voice conditioning latent space.
  
  ### Provided voices
  
  This repo comes with several pre-packaged voices. You will be familiar with many of them. :)
  
  Most of the provided voices were not found in the training set. Experimentally, it seems that voices from the training set
  produce more realistic outputs then those outside of the training set. Any voice prepended with "train" came from the
  training set.
  
  ### Adding a new voice
  
  To add new voices to Tortoise, you will need to do the following:
  
  1. Gather audio clips of your speaker(s). Good sources are YouTube interviews (you can use youtube-dl to fetch the audio), audiobooks or podcasts. Guidelines for good clips are in the next section.
  2. Cut your clips into ~10 second segments. You want at least 3 clips. More is better, but I only experimented with up to 5 in my testing.
  3. Save the clips as a WAV file with floating point format and a 22,050 sample rate.
  4. Create a subdirectory in voices/
  5. Put your clips in that subdirectory.
  6. Run tortoise utilities with --voice=<your_subdirectory_name>.
  
  ### Picking good reference clips
  
  As mentioned above, your reference clips have a profound impact on the output of Tortoise. Following are some tips for picking
  good clips:
  
  1. Avoid clips with background music, noise or reverb. These clips were removed from the training dataset. Tortoise is unlikely to do well with them.
  2. Avoid speeches. These generally have d