API

Version : v1.6

Date : 30th April 2023

Notes :
- In POST v1/synthesize, added support for model v4.0
- Model removes some high frequency noise seen with earlier versions
- Added support for noise_scale where the noise filtering can be controlled
- Default v4.0 (older models supported under v3.3, v3.2, v3.1, v3.0, v2.0, v1.x)

Version : v1.5

Date : 21st December 2022

Notes :
- In POST v1/synthesize, added support for model v3.3 which supports dynamic pitch/pace transformation
- Default v3.3 (older models supported under v3.2, v3.1, v3.0, v2.0, v1.x)

Version : v1.4

Date : 4th September 2022

Notes :
- In POST v1/synthesize, added support for model v3.2 which is more efficient for synthesizing breaks
- Default v3.2 (older models supported under v3.1, v3.0, v2.0, v1.x)

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

  • To get the initial tokens to get started, users to login to mozhi.me and go to “Tokens” page
  • Click “Show Tokens” to get the access_token and refresh_token

Note :

  • ‘access_token’ is valid for 1 day, and ‘refresh_token’ is valid for 365 days
  • Using refresh_token, additional access_tokens can be generated using the APIs defined in Token Management
  • Please keep the access_token and refresh_token SAFE and SECURE.

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 :

  • For using the Token Management API, access_token has to be valid.
  • Incase access_toke has expired, please login to to mozhi.me and go to “Tokens” page to manually trigger SignOut (COMING SOON)

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

  • text : Input text to be synthesized (mandatory)
  • spkr : speaker to be used for synthesis (mandatory) -- valid values : "FEMALE1_CUSTOM", "FEMALE2_CUSTOM", "FEMALE3_CUSTOM", "FEMALE4_CUSTOM", "FEMALE5_CUSTOM", "FEMALE6_CUSTOM", "FEMALE7_CUSTOM", "FEMALE8_CUSTOM", "FEMALE9_CUSTOM", "FEMALE10_CUSTOM", "MALE1_CUSTOM", "MALE2_CUSTOM", "MALE3_CUSTOM", "MALE4_CUSTOM", "MALE5_CUSTOM", "MALE6_CUSTOM", "MALE7_CUSTOM", "MALE8_CUSTOM", "MALE9_CUSTOM", "MALE10_CUSTOM"
  • modelver : model version to be used (default: 'v4.0')
    -- 'v4.0' : support for noise filtering
    -- 'v3.3' : dynamic pitch and pace transforms, along with dynamic break durations for punctuation
    -- 'v3.2' : efficient synthesis for breaks in sentences due to punctuation
    -- 'v3.1' : support for punctuations and read along with text highlighting
    -- 'v3.0' : support for punctuations
    -- 'v2.0' : more naturally sounding
    -- 'v1.1' : efficiency improvements
    -- 'v1.0' : initial model (to be deprecated in future releases)
  • num (optional, default : ml):
    -- “ml” : to synthesize numbers in malayalam
    -- “en” : to synthesize numbers in english
  • noise_scale (optional, default : 0) :
    -- Control the noise scaling of the synthesized audio. Valid range [0, 0.5], from modelver v4.0 onwards
  • pace_scale (optional, default : 1.0) :
    -- Control the pace of the synthesized audio. Valid range [0.5, 2], 'dynamic' from modelver v3.3 onwards
  • pitch_scale (optional, default : 1.0)
    -- Scale the pitch of the synthesized audio. Valid range [0.5, 1.5], 'dynamic' from modelver v3.3 onwards
  • pitch_shift (optional, default : 0.0):
    -- Shift the pitch of the synthesized audio. Valid range [-50, 50], 'dynamic' from modelver v3.3 onwards
  • punctution_breaks (optional, default : None):
    -- Randomize breaks in punctuation by +/-10% Valid : None, 'dynamic' from modelver v3.2 onwards

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>
'durations' : list of list with each element of the list having [word(s), start_seconds, duration_seconds, end_seconds]
}

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

  • jobid : jobid to be queried (mandatory)

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 :

  • Valid ‘access_token’ needed for issuing the command
  • ‘access_token’ is valid for 1 day, and ‘refresh_token’ is valid for 365 days
  • If ‘access_token’ has expired, and needs to signout, users can login to https://mozhi.me and go to “Tokens” page
  • If ‘access_token’ has expired, and needs to revoke, users can login to https://mozhi.me and go to “Tokens” page

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'}"
Select your color
Theme Options