A simple script that uses the OpenAI Text-to-Speech
API
to generate and download sample audio files with the built-in voices.
π§ Useful for: - Testing different voices locally\
- Prototyping AI voice apps\
- Creating quick audio demos
-
Install tsx globally:
npm install -g tsx
-
Install other project dependencies:
npm install
-
Get your OpenAI API key from:
π https://platform.openai.com/api-keys
Run the script with your API key:
tsx src/main --apiKey=<OPEN_API_KEY>The script will: - Call the OpenAI TTS API\
- Model used
gpt-4o-mini-tts - Generate
.mp3files for each built-in voice\ - Save them to your local machine
You'll find the generated audio files inside the assets/voices folder, named
after each voice (e.g., alloy.mp3, echo.mp3, fable.mp3).
- Make sure your API key has access to the TTS models.\
- By default, the sample text is included for each built-in voice, but
you can customize this in the
voicesconfig.