Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.86 KB

File metadata and controls

50 lines (35 loc) · 1.86 KB

SPEAK

This is sample code for using TTS (text-to-speech), also known as a speech synthesizer. It is available in JavaScript and Python.

To use this tool with the OpenAI Text-to-Speech API, set the following environment variables:

export TTS_API_BASE_URL=https://api.openai.com/v1
export TTS_API_KEY="your_api_key_here"
export TTS_MODEL="tts-1"
export TTS_VOICE="alloy"

To use this tool with Supertonic 3, first run the server, then set the following environment variables:

export TTS_API_BASE_URL=http://127.0.0.1:7788/v1
export TTS_MODEL="supertonic-3"
export TTS_VOICE="F3"
export TTS_AUDIO_FORMAT=wav

To use this tool with Kokoro-FastAPI, first run the container, then set the following environment variables (see the full list of voices):

export TTS_API_BASE_URL=http://127.0.0.1:8880/v1
export TTS_MODEL="kokoro"
export TTS_VOICE="af_bella"

To use this tool with piper-tts-http-server, first run the container, then set the following environment variables (see the full list of voices):

export TTS_API_BASE_URL=http://127.0.0.1:5000/v1
export TTS_MODEL="piper"
export TTS_VOICE="en_US-ryan-medium"

Synthesizing Speech

To synthesize speech, run:

./speak.js "Jupiter is the largest planet in our solar system."
./speak.py "Jupiter is the largest planet in our solar system."

This will generate an MP3 audio file. If SoX is installed, it will automatically play the audio.