This script allows you to convert text files to speech using the ElevenLabs API. It reads text files from a specified input folder, generates speech using the API, and saves the resulting audio files in an output folder.
- Python 3.x
- ElevenLabs API key (sign up at ElevenLabs website)
-
Clone or download the script to your local machine.
-
Install the required Python packages by running the following command:
pip install elevenlabs
Before running the script, you need to set up the following variables in the script:
set_api_key("<YOUR_API_KEY_HERE>")
: Replace<YOUR_API_KEY_HERE>
with your actual ElevenLabs API key.voice = "Your_Voice_id"
: SetYour_Voice_id
to your preferred voice ID. You can find the available voice IDs in the ElevenLabs API documentation.model = "elevenlabs_monolingual_v1"
: Setelevenlabs_monolingual_v1
to your preferred model. You can find the available models in the ElevenLabs API documentation.input_folder = "path/to/input/folder"
: Setpath/to/input/folder
to the path of the folder containing your input text files.output_folder = "path/to/output/folder"
: Setpath/to/output/folder
to the path where you want to save the output audio files.
-
Place your text files in the input folder specified in the script.
-
Open a terminal or command prompt and navigate to the directory containing the script.
-
Run the following command to execute the script:
python app.py
-
The script will convert each text file in the input folder to speech using the ElevenLabs API and save the resulting audio files in the output folder.
-
Once the script has finished processing all the files, you will find the converted audio files in the output folder.
- Ensure that you have a stable internet connection while running the script, as it requires access to the ElevenLabs API.
- Make sure that the input and output folders exist before running the script. The script will not create the folders automatically.
- The script uses the
.txt
extension to identify the input text files. Only files with the.txt
extension will be processed.
This project is licensed under the terms of the MIT license.