How To Use 
Register an account

Try For Free Now

Dark

Light

Announcement: Change of trial usage for new individual user (6/21)

Announcemnet: System Maintenance (Update: July 19)

Announcement: Change of trial usage for new individual user (6/21)

TEXT TO SPEECH
Speech Synthesis
Convert text to a speech synthesis file.
Endpoint
Request details
POST
https://translate.rozetta-api.io/api/v1/translate/tts
Header
Header
Description
Content-Type
application/json
accessKey, nonce, signature
Please refer to the authentication section.
Body
Key
Required
Description
targetLang
O
The language of the text. Please use the ISO 639-1 code. English, Japanese and Chinese are supported now.
text
O
Original text. Specify the text to be translated, up to 8000 bites(about 2000 Chinese characters). This field is required.
contractId
Contract ID. For user who has one contract, the field can be omitted. For user who has two or more contracts, it's required to specify the contractId. (e.g. User who has a Text translation contract and a Speech translation contract, has to specify the contract ID)
Request Sample
{
    "text": "Hello. Have a nice day!",
    "targetLang": "en"
}
Response
Key
Description
N/A
The synthesized speech file in WAV format.
Response Sample
<wav File Byte Array>

api/v1/translate/tts
Convert text to speech synthesis file.
const fs = require('fs');
const https = require('https');
const crypto = require('crypto');

const authUtils = require('./utils/auth-utils');

const serverConfig = {
 protocol: 'https:',
 hostname: 'translate.rozetta-api.info',
 port: 443
};
const authConfig = {
 accessKey: 'ACCESS_KEY',
 secretKey: 'SECRET_KEY',
 nonce: Date.now().toString()
};
const data = {
 text: 'こんにちは、いい天気ですね。',
 targetLang: 'ja',
 contractId: 'your contractId'
};
const speechFile = 'speech.wav';

const getSpeechResult = (serverConfig, authConfig, data) => {
 const path = '/api/v1/translate/tts';
 const signature = authUtils.generateSignature(
   path,
   authConfig.secretKey,
   authConfig.nonce
 );
 const requestOptions = {
   protocol: serverConfig.protocol,
   host: serverConfig.hostname,
   port: serverConfig.port,
   method: 'POST',
   path,
   headers: {
     accessKey: authConfig.accessKey,
     signature,
     nonce: authConfig.nonce,
     'Content-Type': 'application/json'
   }
 };

 return new Promise((resolve, reject) => {
   const request = https.request(requestOptions, (response) => {
     const writeStream = fs.createWriteStream(speechFile);
     response.pipe(writeStream);
     response.on('close', () => {
       resolve();
     });
   });
   request.on('error', (error) => {
     reject(error);
   });
   request.write(JSON.stringify(data));
   request.end();
 });
};

const main = async () => {
 try {
   await getSpeechResult(serverConfig, authConfig, data);
   console.log('Speech file downloaded to:');
   console.log(speechFile);
 } catch (error) {
   console.error(error);
 }
};

main();
About the authentication, please refer to the authentication section.
About full sample code of each languages, please refer tohere
©️ 2019 Rozetta API  ・  Powered by Rozetta

Rozetta Corp.

^