Text to speech synthesis

speech/synthesis@1.0.1
Supported by 2 providers
GS
IS

Text to speech synthesis

Convert text into speech synchronously.

Input
Text
Voice
Audio
Result
Audio content

1.Choose a provider

2.Use TextToSpeechSynthesis with mock in your code

npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

const sdk = new SuperfaceClient();

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();

Structure details

Input (object)

text
The text input to be synthesized.
voice
Voice selection options.
audio
Audio format options.

Example

{
  "text": "Hello world.",
  "voice": {
    "languageCode": "en-US"
  },
  "audio": {
    "encoding": "linear_pcm"
  }
}

Result (object)

audioContent
Synthesised audio data bytes encoded as specified in the audio options input.

Example

{
  "audioContent": "<Synthesised audio data bytes encoded as 16-bit signed little-endian samples with WAV header>"
}

Implementation details

Provider
mock
Use case
TextToSpeechSynthesis
Author
@superface
Source
Verified