This tool is a command-line utility for processing large amounts of text using OpenAI's Text-to-Speech (TTS) API, like reading article or books. It reads a text file, splits it into chunks, converts each chunk into speech using OpenAI TTS, and finally merges the resulting audio files into a single output file.
Before using this tool, ensure you have the following:
- Node.js installed on your machine
- OpenAI API key
- ffmpeg installed on your machine (for merging audio files)
- A text file containing the text you want to convert to speech
-
Clone this repository:
git clone https://github.com/AlexRazor1337/article-to-audio
-
Navigate to the project directory:
cd article-to-audio
-
Install dependencies:
npm install
-
Create a
.env
file in the project root and add your OpenAI API key:OPENAI_API_KEY=your-api-key
Other optional parameters can be added to the
.env
file. See the Configuration section for details.
-
Place the text you want to convert in a file named
input.txt
in the project root or pass it as first argument or set it in.env
file. -
Run the tool:
node index.js
-
Follow the on-screen instructions. Press any key to start the processing.
-
The tool will create an
audio
folder in the project directory and generate individual audio files for each chunk. -
After processing all chunks, the tool will merge the audio files into a single output file named
output.mp3
or what you have specified as second argument or.env
file. -
Once the merging is complete, the intermediate audio files will be deleted, leaving only the output file.
You can customize the following parameters in the .env
file:
MAX_PARALLEL
: The maximum number of chunks to process simultaneously. Defaults to5
.MAX_CHUNK_SIZE
: The maximum size of each chunk in characters. Defaults to3000
.TTS_MODEL
: TTS model to use. Defaults totts-1
.TTS_VOICE
: TTS voice to use. Defaults toecho
.INPUT_FILE
: Name of the input file. Defaults toinput.txt
.OUTPUT_FILE
: Name of the output file. Defaults tooutput.mp3
.
This tool is provided as-is, and the user is responsible for compliance with OpenAI's usage policies and terms.
This tool is licensed under the MIT License. See the LICENSE file for details.