Skip to content

Instantly share code, notes, and snippets.

@seankross
Last active April 28, 2023 16:55
Show Gist options
  • Save seankross/09157c09196b33fd988857cb2b2a85aa to your computer and use it in GitHub Desktop.
Save seankross/09157c09196b33fd988857cb2b2a85aa to your computer and use it in GitHub Desktop.
Get TTS working in R with Reticulate on M1 or M2 MacOS

Make sure homebrew is all up to date.

Make sure you have venv working, I think it just comes with python3.

Start a brand new RStudio project and open it in RStudio.

In the terminal:

python -m venv .venv
source .venv/bin/activate

In the terminal but make sure to copy the output:

which python

In the terminal:

brew install mecab
python -m pip install mecab-python3
python -m pip install TTS

In R:

Sys.setenv(RETICULATE_PYTHON = "[path result of which python]")
library(reticulate)
tts <- import("TTS.api")
tts$TTS$list_models()[1:5]
@howardbaek
Copy link

This just needs a library(reticulate) before tts <- import("TTS.api"), but otherwise, this works!

@seankross
Copy link
Author

🎉🎉🎉

@howardbaek
Copy link

howardbaek commented Apr 28, 2023

One other comment:

In RStudio's Terminal, python -m venv .venv doesn't work: bash: python: command not found.
If you want to run this in RStudio, you need to add a 3: python3 -m venv .venv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment