text2speech
text2speech copied to clipboard
PATH dilemma in `system()`
This issue stems from a discussion with @seankross .
Background
In macOS, I installed coqui TTS and started using it in the Terminal. To search for the path to the tts
library, I type which tts
in the Terminal, which outputs /opt/homebrew/Caskroom/miniforge/base/bin/tts
. To check whether users of text2speech
had installed tts
, I wanted to replicate this command in this package using system("which tts")
, which returns an object with an attribute
of status 1 (failure).
Problem
This has to do with the PATH environment variable. When I run system("PATH=\"/opt/homebrew/Caskroom/miniforge/base/bin\" /usr/bin/which tts")
, or system2("/usr/bin/which", "tts", env = "PATH=\"/opt/homebrew/Caskroom/miniforge/base/bin\"")
, I get an 0 error code (success). Its nice that I get the correct path to tts
, when I manually specify its path, but I want to programmatically find the PATH without needing to manually provide it to R.
Alternative
I can ask the user to provide the PATH (for ex, /opt/homebrew/Caskroom/miniforge/base/bin
), and I can check if system("PATH=\"/opt/homebrew/Caskroom/miniforge/base/bin\" /usr/bin/which tts")
returns a status code of 0 (success).