Sound of Text

API Documentation

Index

Introduction

The Sound of Text API will give you all the same functions as the website. The API is currently free and there are no plans to change that. That being said, it's not free for me to host, so please don't abuse it. If you have any questions or experience difficulties, please feel free to contact me directly via email or twitter.

The API itself is located at https://api.soundoftext.com and it supports two operations. The first allows you to create a sound, returning an id. The second allows you to get the public url for the sound from an id. Check out the reference for more details.

Client Libraries

You might find it useful to use a library that already handles some of the implementation details for the Sound of Text API. If you write one yourself, please let me know so that I can add it to the list!

Supported Voices

There are a finite number of supported voices that the API supports. I manually curated the voices from Google Translate, so voices might be added (or removed) at any time. Always use the shortened voice/language code, never the full name, when using the API.

CodeVoice

Reference

POST /sounds

Use this operation to create a new sound. Currently the engine parameter is ignored, but it is included because more engines might be used in the future. Both voice and text are required parameters.

Request

Set your Content-Type header to application/jsonand make your request body look like the following:

{
  "engine": "Google",
  "data": {
    "text": "Hello, world",
    "voice": "en-US"
  }
}

Response

On Success

An HTTP status code of 200 with response body:

{
  "success": true,
  "id": "<RFC4122 uuid>"
}

IDs look like this: "416eda90-552e-11e7-9a60-63d42f732a9c".

On Failure

An HTTP status code of 400 or 500 with response body:

{
  "success": false,
  "message": "Request failed due to..."
}

GET /sounds/:id

Use this operation to get the current status of the requested sound and to retrieve the public url for the mp3 file.

Response

On Success

First the sound will be pending if the server has not finished fulfilling the request.

{
  "status": "Pending"
}

Once the request has been fulfilled, you will receive a "Done" status and the public url for the mp3 file.

{
  "status": "Done",
  "location": "https://hostname/path/to/audio.mp3"
}

If something went wrong fulfilling the request, you will receive an error status and a message.

{
  "status": "Error",
  "message": "Failed to create sound due to..."
}