മൊഴി mozhi

| അക്ഷരത്തിൽ നിന്നും ശബ്ദം | text to speech |


| login | | home | | updates | | contact |

API

Version : v1.3

Date : 12th August 2022

Notes :
- In POST v1/synthesize, added support for model v3.1 with support for punctuation and read along
- Default v3.1 (older models supported under v3.0, v2.0, v1.x)

Version : v1.2

Date : 10th July 2022

Notes :
- In POST v1/synthesize, added support for model v3.0 with support for punctuation
- Default v3.0 (older models supported under v2.0, v1.x)

Version : v1.1

Date : 19th May 2022

Notes :
- In POST v1/synthesize, added support for multiple model versions
- Default v2.0, older models supported under v1.x)

Version : v1.0

Date : 5th May 2022

Notes :
- Initial release

Tokens

Note :

WARNING !!

Please read carefully on how to invalidate the tokens, if you suspect that the tokens got compromised In case you suspect access_token got compromised, please use the ‘revoke’ command in the Token Management API. Using ‘signout’ in the Token Management API signouts the user from all devices.

Note :

Synthesize Audio

Resource : POST v1/synthesize
URL base : https://api.mozhi.me/

Description

Submit the job for synthesizing audio from text. If the input arguments are proper, return the job id.

Input arguments

Output

Success messages

a) Job is submitted successfully and return

statusCode  : 201
body : {
'status' : 'PROCESSING', 
'jobid'  : <jobdid>, # alphanumeric string corresponding to the job submitted 
'timestamp' : <timestamp>
}

b) If this request is previously successfully completed, then returns the filename.

statusCode  : 200
body : {
'status' : 'SUCCESS', 
'output'  : <output>, # alphanumeric string pointing to the output file of synthesized audio
'timestamp' : <timestamp>
}

c) If same request is submitted within 60 seconds, previously submitted job id is returned

statusCode  : 202
body : {
'status' : 'SUCCESS', 
'jobid' :   <jobid> # alphanumeric string corresponding to the previous job submitted 
}

Fail messages

StatusCode : 
- 400 : input arguments not proper
- 401 : Unauthorized access
- 402 : Payment Required
- 500 : Server error, Please contact 

Example Usage

Python
import requests
import json
api_url = 'https://api.mozhi.me/v1/synthesize'
headers = {
'authorization': <access_token>',
'Content-Type': 'application/json'
}
body = {'text' : 'hello' , 'spkr' : 'FEMALE1_CUSTOM', 'num': 'ml', 'pace_scale' : 1.0, 'pitch_scale' : 1.0, 'pitch_shift' : 0,}
response = requests.request("POST", api_url, headers=headers, data=json.dumps(body))

cURL

curl --location --request POST 'https://api.mozhi.me/v1/synthesize' --header 'Authorization:<access_token>' -H 'Content-Type: application/json' --data-raw "{'text' : 'dum dum' , 'pace_scale' : 1.0,  'pitch_scale' : 1.0,  'pitch_shift' : 0,  'spkr' : 'FEMALE1_CUSTOM'}"

Poll status

Resource : GET v1/status
URL base : https://api.mozhi.me/

Description

Get the status of the job id

Input arguments

Output

Success messages

a) If this request is previously successfully completed, then returns the filename.

statusCode : 200
body : {
    'output' : <ouput> is the alphanumeric string pointing to the output file of synthesized audio
    'status'  : SUCCESS
}

b) Job is still under process

statusCode : 201
body : {
    'status' : PROCESSING
    }

Fail messages

statusCode : 
- 400 : Job id not provided
- 403 : Forbidden to query job id by this user
- 404 : Job id does not exist
- 500 : Server Error, Please contact

Example Usage

Python

import requests
api_url = 'https://api.mozhi.me/v1/status'
headers = {
'authorization': '<access_token>',
'Content-Type': 'application/json'
}
body = "{'jobid' : '<jobid>'}"
response = requests.request("GET", api_url, headers=headers, data=body)

cURL

curl --location --request GET 'https://api.mozhi.me/v1/status' --header 'Authorization:<access_token>' -H 'Content-Type: application/json' --data-raw  "{'jobid' : '<jobid>'}"

Token management

Resource : GET v1/tokens
URL base : https://api.mozhi.me/

Description : Get the status of the job id

Input arguments

'command' : (mandatory) - ‘refresh’ #issues command to generate access token using the refresh_token provided in the header - ‘revoke’ : Revokes all of the access tokens generated by the refresh_token provided in the header - ‘signout’ : Signs out users from all devices. It also invalidates all refresh tokens issued to a user.

Note :

Output

Success messages

a) command : ‘refresh’

statusCode : 200
body : {
    'AccessToken'  : Alphanumeric string to be used in header for authorizing the requests
    }

b) command : revoke

statusCode : 200
body : 'all access_tokens generated by provided refresh_token revoked'

c) command : signout

statusCode : 200
body'  : 'all refresh_tokens invalidated'

Error messages

statusCode : 
- 400 : Valid command not provided
- 401 : Unauthorized  access_token has expired
- 403 : access_token or refresh_token revoked
- 500 : Server Error, Please contact

Example Usage

Python

import requests
api_url = 'https://api.mozhi.me/v1/tokens'
headers = {
        'Authorization' : '<access_token>',
        'refresh_token' : '<refresh_token>',
        'Content-Type'  : 'application/json'
        }
body = "{ 'command' : 'refresh'}"
response = requests.request("POST", api_url, headers=headers, data=body)

cURL

curl --location --request POST 'https://api.mozhi.me/v1/tokens' \
--header 'Authorization:<access_token> \
-H 'refresh_token: <refresh_token> \
-H 'Content-Type: application/json' \
--data-raw  "{'command' : 'refresh'}"