Pricing 
API Pricing

Try For Free Now

Dark

Light

SPEECH TO TEXT
Speech-to-Text
Extract transcript from a speech file.
Endpoint
Request details
POST
https://translate.rozetta-api.io/api/v1/translate/stt
Header
Header
Description
Content-Type
multipart/form-data
accessKey, nonce, signature
Please refer to the authentication section.
Body
Key
Required
Description
sourceLang
O
The language of the audio. Supported languages: English(en), Japanese(ja), Chinese (Simplified)(zh-CN), Chinese (Traditional)(zh-TW)
audioFile
O
The audio file for speech recognition. The file must use WAV format and should be less than 60 seconds, bitrate and sampling rate must be 16bps and 16kHz respectively.
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
curl -X POST -H "nonce: Your Nonce" -H "accessKey: Your Access Key" -H "signature: Your Signature" -H "Content-Type: multipart/form-data" -F "audioFile=@Your File Path" -F "sourceLang=ja" https://translate.rozetta-api.io/api/v1/translate/stt
Response
Key
Description
result
The transcript extracted from the speech.

api/v1/translate/stt
Submit speech file for speech recognition.
JavaScript
C#
const FormData = require('form-data');

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

const serverConfig = {
 protocol: 'https:',
 hostname: 'translate.rozetta-api.io',
 port: 443
};
const authConfig = {
 accessKey: 'ACCESS_KEY',
 secretKey: 'SECRET_KEY',
 nonce: Date.now().toString()
};
const speechConfig = {
 lang: 'ja',
 audioFile: 'speech.wav',
 contractId: 'your contractId'
};

const sendRequest = (serverConfig, authConfig, speechConfig) => {
 const form = new FormData();
 form.append('sourceLang', speechConfig.lang);
 form.append('audioFile', fs.createReadStream(speechConfig.audioFile));
 form.append('contractId', speechConfig.contractId);

 const path = '/api/v1/translate/stt';
 const signature = authUtils.generateSignature(
  path,
  authConfig.secretKey,
  authConfig.nonce
);
 return new Promise((resolve, reject) => {
   form.submit(
     {
       protocol: serverConfig.protocol,
       host: serverConfig.hostname,
       port: serverConfig.port,
       path,
       headers: {
         accessKey: authConfig.accessKey,
         signature,
         nonce: authConfig.nonce
       }
     },
     (error, response) => {
       if (error !== null) {
         reject(error);
         return;
       }
       response.setEncoding('utf8');
       let data = '';
       response.on('data', (chunk) => {
         data += chunk;
       });
       response.on('end', () => {
         resolve(data);
       });
     }
   );
 });
};

const main = async () => {
 try {
   const response = await sendRequest(
     serverConfig,
     authConfig,
     speechConfig
   );
   console.log('Server response:');
   console.log(response);
 } catch (error) {
   console.error(error);
 }
};

main();
About the authentication, please refer to the authentication section.
You can get a full version of sample codes here
©️ 2019 Rozetta API  ・  Powered by Rozetta

Rozetta Corp.

^