Speech.sh
by j3k0
Speech.sh is a command-line utility for converting text to speech using OpenAI's API. It offers multiple voice options, adjustable speech speed, and flexible API key management.
Last updated: N/A
What is Speech.sh?
Speech.sh is a powerful command-line utility that leverages OpenAI's API to convert text into spoken audio. It provides a simple and efficient way to generate speech from text directly from your terminal.
How to use Speech.sh?
To use Speech.sh, first clone the repository and make the scripts executable. Then, use the speech.sh
script with the --text
option to specify the text you want to convert. You can customize the voice, speed, and output file using additional options. The API key can be provided via command-line, environment variable, or a file.
Key features of Speech.sh
Convert text to speech with a simple command
Multiple voice options
Adjustable speech speed
Support for both tts-1 and tts-1-hd models
Flexible API key management
Automatic caching
Robust retry mechanism
MCP compatibility
Use cases of Speech.sh
Generating audio for tutorials
Creating audiobooks
Adding voice to command-line tools
Integrating with AI assistants
Accessibility for visually impaired users
FAQ from Speech.sh
How do I set my OpenAI API key?
How do I set my OpenAI API key?
You can set your API key using the --api_key
command-line argument, the OPENAI_API_KEY
environment variable, or by creating a file named API_KEY
in the script's directory.
What voice options are available?
What voice options are available?
The available voice options are onyx, alloy, echo, fable, nova, and shimmer.
How do I change the speech speed?
How do I change the speech speed?
Use the --speed
option followed by a value between 0.25 and 4.0.
How does caching work?
How does caching work?
The script caches audio files based on the text, voice, and speed. If you request the same combination, it will reuse the cached file to avoid unnecessary API calls.
What if the API call fails?
What if the API call fails?
The script includes a retry mechanism with exponential backoff to handle network issues. You can configure the number of retries and timeout values using the --retries
and --timeout
options.