Convert text into speech synchronously.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('speech/synthesis@1.0.1');
// Use the profile
const result = await profile
.getUseCase('TextToSpeechSynthesis')
.perform({
text: 'Hello world.',
voice: {
languageCode: 'en-US'
},
audio: {
encoding: 'linear_pcm'
}
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"text": "Hello world.",
"voice": {
"languageCode": "en-US"
},
"audio": {
"encoding": "linear_pcm"
}
}
{
"audioContent": "<Synthesised audio data bytes encoded as 16-bit signed little-endian samples with WAV header>"
}