Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Text To Speech

Improve this doc

Text to Speech plugin

Repo: https://github.com/vilic/cordova-plugin-tts

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-tts
    $ npm install --save @ionic-native/text-to-speech@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { TextToSpeech } from '@ionic-native/text-to-speech';

constructor(private tts: TextToSpeech) { }

...

this.tts.speak('Hello World')
  .then(() => console.log('Success'))
  .catch((reason: any) => console.log(reason));

Instance Members

speak(textOrOptions)

This function speaks

Param Type Details
textOrOptions string|TTSOptions

Text to speak or TTSOptions

Returns: Promise<any> Returns a promise that resolves when the speaking finishes

stop()

Stop any current TTS playback

Returns: Promise<any>

TTSOptions

Param Type Details
text string

text to speak

locale string

a string like 'en-US', 'zh-CN', etc

(optional)
rate number

speed rate, 0 ~ 1

(optional)

API

Native

General