jhudsl / text2speech

Text to Speech
http://jhudatascience.org/text2speech/
GNU General Public License v3.0
19 stars 2 forks source link

Install tts with `reticulate` #16

Open howardbaik opened 1 year ago

howardbaik commented 1 year ago

If we can't programmatically find tts, and the user knows that tts isn't installed on their system, we install it for them with pip install tts using reticulate

Tasks

muschellij2 commented 1 year ago

I'll defer to you, but I think adding reticulate as a dependency is a large lift for this package. If you do go this route, make sure it's a most a Suggests not Imports.

howardbaik commented 1 year ago

I agree that adding reticulate is a heavy dependency for this package. And we have to decide whether text2speech wants to call tts through a virtual environment using reticulate or keep it as is and just have the user use terminal to supply the path.

One benefit of using reticulate to run tts in Python is voice cloning:

Screenshot 2023-05-10 at 1 00 33 PM

Me and @cansavvy agree we can put this issue on the shelf while we work on other issues.

For posterity

Using reticulate to call tts

I was able to install tts using reticulate:

library(reticulate)

# Create a new environment 
virtualenv_create("r-reticulate")
# Install TTS
virtualenv_install(packages = "TTS")
# Use r-reticulate as virtual environment
use_virtualenv("r-reticulate")

If you get this error message ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with LibreSSL 2.8.3. See: https://github.com/urllib3/urllib3/issues/2168, remove urllib3 and install urllib3<2.0:

# Do `pip uninstall urllib3` 
virtualenv_remove("urllib3")
# Do `pip install 'urllib3<2.0'`
virtualenv_install("urllib3<2.0")

Create a Python script (script.py):

from TTS.api import TTS

# List available 🐸TTS models and choose the first one
model_name = TTS.list_models()[0]
# Init TTS
tts = TTS(model_name)
# Run TTS
# Text to speech to a file
tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")

⚠️ This crashes RStudio for some reason...