Closed gvimlag closed 2 years ago
Sure, this is pretty straightforward with curl
:
echo 'This is a test.' | \
curl -X POST -H 'Content-Type: text/plain' --data-binary @- --output - 'http://localhost:5002/api/tts?voice=en' \
> test.wav
Hope this helps :slightly_smiling_face:
synesthesiam, thank you for your response. It led to the solution! I made one change (changed "> test.wav" to "| aplay -q -r 22050 -c 1 -f S16_LE").
echo "This is a test." |\
curl -X POST -H 'Content-Type: text/plain' --data-binary @- --output - 'http://localhost:5002/api/tts?voice=en' \
| aplay -q -r 22050 -c 1 -f S16_LE
I've discovered a possible bug: (Should I post this problem as a separate issue?) When one specifies the voice directory with "larynx-server --voice-dir NewDirectory"; the new voice files are NOT downloaded into this directory.
Below are examples showing this problem when downloading the "ljspeech" voice files:
EXAMPLE-1: FAILS. "larynx-server" downloads the voice files into the WRONG directory
Terminal-1: sudo larynx-server --voices-dir /usr/lib/larynx-tts/local #specify the new voice directory
Terminal-2: echo "This is a test." | curl -s -X POST -H 'Content-Type: text/plain' --data-binary @- --output - 'http://localhost:5002/api/tts?voice=ljspeech' | aplay -q -r 22050 -c 1 -f S16_LE
Terminal-2: sudo updatedb #update database of mlocate
Terminal-2: sudo locate ljspeech #locate voice files
Output: WRONG_directory
Terminal-2: sudo rm -rf WRONG_directory #cleanup for next test
EXAMPLE-2: WORKS. "larynx" (NOT "Larynx-server") downloads the voice files into CORRECT directory
Terminal-1: sudo larynx --voices-dir /usr/lib/larynx-tts/local -v ljspeech "This is a test." | aplay -q -r 22050 -c 1 -f S16_LE #specify the new voice directory
Terminal-1: sudo updatedb #update database of mlocate
Terminal-1: sudo locate ljspeech #locate voice files
Output: /usr/lib/larynx-tts/local/us-en/ljspeech-glow_tts/<files> #CORRECT directory!
Terminal-1: sudo rm -rf /usr/lib/larynx-tts/local/us-en/ljspeech-glow_tts #cleanup for next test
Again, synesthesiam, thank you for your help.
Impressive program!
Using a bash script, how do I send text to the larynx SERVER?
When using the larynx CLI, there is a 5-15 second startup delay (which I'm trying to eliminate). So I'd like to start a server, then send the text to the server to avoid this startup delay.
Unfortunately, I've failed to find documentation or an example on how to connect to the server using a bash script. I've experimented with the "--daemon" option, and studied the larynx-server example, but failed to find a solution. (Please forgive my inexperience with TTS.)
I'd appreciate an example (or pointer to documentation) showing how to send text to the larynx server using a bash script. Thank you.