Narakeet Text to Speech Streaming API example in Java
This repository provides a quick example demonstrating how to access the Narakeet streaming Text to Speech API from Java.
The example sends a request to generate audio from text and saves it output.mp3
in the local directory.
Prerequisites
To use this example, you will need Java 8 or later, and Maven 3 or later, and an API key for Narakeet.
The example uses the org.apache.http
library to execute HTTPS requests.
Running the example
- run
mvn install
to download the dependencies - edit src/main/java/com/narakeet/Example.java and change the voice and the text that will be sent to the API.
- set the NARAKEET_API_KEY environment variable to contain your API key
- run
mvn compile exec:java
- check
output.mp3
to play the downloaded file
Running the example from Docker
For easy development, this repository also includes a Docker container with Amazon Correto 8, which can be used to run the conversion without installing Java locally. To use Docker:
- run
make init
to create the Docker image locally - run
make bootstrap
to download Maven dependencies - run
make execute NARAKEET_API_KEY=<YOUR API KEY>
to produce the result file. - check
output.mp3
to play the downloaded file
More information
Check out https://www.narakeet.com/docs/automating/text-to-speech-api/ for more information on the Narakeet Text to Speech API