This repository provides a quick example demonstrating how to access the Narakeet streaming Text to Speech API from Python.
The example sends a request to generate audio from text and saves it output.m4a in the local directory.
The example uses the requests python library to send HTTPS requests to the Narakeet API.
Note that Narakeet also has a text to speech API to generate long content, suitable for larger conversion tasks. See the Long Content Text to Speech API Example for more information on how to use that.
To use this example, you will need Python (3.7 or more recent), and an API key for Narakeet.
You can run the example using Docker without a local Python installation, using the following command line (replace YOUR_NARAKEET_API_KEY with your Narakeet API key):
make run NARAKEET_API_KEY=YOUR_NARAKEET_API_KEY
- export and set the environment variable
NARAKEET_API_KEYwith your API key, or edit tts.py and add your API key on line 2, instead of reading the environment variable. You can optionally modify the voice and text parameters on lines 2 and 3, which control the text to speech synthesis voice and the text sent to the API for synthesis. - run
pip install -r requirements.txtto install the required libraries - run
python tts.pyto create the output audio.
Check out https://www.narakeet.com/docs/automating/text-to-speech-api/ for more information on the Narakeet Text to Speech API