Superface

Text to speech synthesis

speech/synthesis@1.0.1
2 providers

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

Below instructions are for our Node.js SDK. Use OneService for other languages.
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();

Structure details

Input (object)

text
The text input to be synthesized.
voice
Voice selection options.
languageCode
The language (and potentially also the region) of the voice expressed as a BCP-47 language tag, e.g. 'en-US'.
name
The name of the voice.
audio
Audio format options.
encoding
The format of the audio byte stream.
sampleRateHertz
The synthesis sample rate in hertz for the audio. Selected sample rate has to be supported by selected audio encoding format.

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