All Projects → nativescript-community → texttospeech

nativescript-community / texttospeech

Licence: MIT license
Text to Speech NativeScript plugin for Android & iOS 📢

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to texttospeech

nativescript-app-shortcuts
👇 Home Icon Actions for your NativeScript app, now also for Android!
Stars: ✭ 45 (+2.27%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-image-filters
NativeScript plugin to apply filters to images
Stars: ✭ 30 (-31.82%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-fabric
Handling App URLs in nativescript apps
Stars: ✭ 29 (-34.09%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-drawingpad
📝 NativeScript plugin to provide a way to capture any drawing (signatures are a common use case) from the device
Stars: ✭ 89 (+102.27%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-store-update
No description or website provided.
Stars: ✭ 18 (-59.09%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-appversion
🔢 NativeScript plugin to retrieve your app's package ID and current version
Stars: ✭ 47 (+6.82%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-http
The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning
Stars: ✭ 32 (-27.27%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-taptic-engine
📳 Use Apple's Taptic Engine to vibrate your iPhone 6s (and up) in a variety of ways
Stars: ✭ 16 (-63.64%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-vue-multi-drawer
A NativeScript-Vue component for creating multiple side drawers (4 sides supported)
Stars: ✭ 45 (+2.27%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-printer
📠 Send an image or the screen contents to a physical printer
Stars: ✭ 33 (-25%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-star-printer
🌟 Print directly to Star Micronics printers from your NativeScript app! http://www.starmicronics.com/
Stars: ✭ 28 (-36.36%)
Mutual labels:  nativescript, nativescript-plugin
Nativescript Vue
Native mobile applications using Vue and NativeScript.
Stars: ✭ 4,784 (+10772.73%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-clipboard
📋 NativeScript plugin to copy stuff to the device clipboard, and read from it again
Stars: ✭ 40 (-9.09%)
Mutual labels:  nativescript, nativescript-plugin
insomnia
😪 NativeScript plugin to keep the device awake (not dim the screen, lock, etc)
Stars: ✭ 40 (-9.09%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-vue-examples
🍈 NativeScript and Vue code samples.
Stars: ✭ 13 (-70.45%)
Mutual labels:  nativescript, nativescript-plugin
ui
Add right-to-left support to the NativeScript framework
Stars: ✭ 22 (-50%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-app-icon-changer
Change the homescreen icon of your NativeScript iOS app at runtime!
Stars: ✭ 16 (-63.64%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-pushy
Easy push notifications for your NativeScript app!
Stars: ✭ 19 (-56.82%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-performance-monitor
⚡ Proof your app maintains 60-ish FPS by collecting data or showing it on screen with this NativeScript plugin!
Stars: ✭ 21 (-52.27%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-homekit
🏡 HomeKit plugin for your fancy NativeScript app
Stars: ✭ 23 (-47.73%)
Mutual labels:  nativescript, nativescript-plugin

npm npm

@nativescript-community/texttospeech 📢

A Text to Speech NativeScript plugin for Android & iOS

Native Controls

Installation

Run the following command from the root of your project:

tns plugin add @nativescript-community/texttospeech

This command automatically installs the necessary files, as well as stores @nativescript-community/texttospeech as a dependency in your project's package.json file.

Video Tutorial

egghead lesson @ https://egghead.io/lessons/typescript-using-text-to-speech-with-nativescript

Usage

/// javascript
const TextToSpeech = require('@nativescript-community/texttospeech');

/// TypeScript
import { TNSTextToSpeech, SpeakOptions } from '@nativescript-community/texttospeech';

const TTS = new TNSTextToSpeech();

const speakOptions: SpeakOptions = {
    text: 'Whatever you like', /// *** required ***
    speakRate: 0.5, // optional - default is 1.0
    pitch: 1.0, // optional - default is 1.0
    volume: 1.0, // optional - default is 1.0
    locale: 'en-GB', // optional - default is system locale,
    finishedCallback: Function, // optional
};

// Call the `speak` method passing the SpeakOptions object
TTS.speak(speakOptions).then(
    () => {
        // everything is fine
    },
    (err) => {
        // oops, something went wrong!
    }
);

API

  • speak(options: SpeakOptions): Promise<any> - start speaking with the given options

  • pause(): void - pause the speech

  • resume(): void - resume the speech

  • destroy(): void - release resources for the speech synthesizer/engine

  • SpeakOptions = {}

    • text: string ** required **
    • queue?: boolean = false
    • pitch?: number = 1.0
    • speakRate?: number = 1.0
    • volume?: number = 1.0
    • locale?: string = default system locale or language
    • finishedCallback?: Function

If you wish to set a custom locale, you need to provide a valid BCP-47 code, e.g. en-US. If you wish to set only a custom language (without a preferred country code), you need to provide a valid ISO 639-1 language code.

The plugin checks whether the supplied locale code has the correct syntax but will not prevent setting a nonexistent codes. Please use this feature with caution.

Example with language code only:

const speakOptions: SpeakOptions = {
    text: 'Whatever you like', // *** required ***
    locale: 'en', // english language will be used
};

Example with locale:

const speakOptions: SpeakOptions = {
    text: 'Whatever you like', // *** required ***
    locale: 'en-AU', // australian english language will be used
};

Tip

  • The speech synthesizer takes a moment to initialize on most devices. A simple way to get around this (tested in the demo app) is to create your new instance of the TNSTextToSpeech and then immediately call the init method . This will force the synthesizer to "warm up" . Now when you call the speak method for your app's functionality it will already have "warmed up" the synthesizer so the delay should be minimal. It's possible this "Warm up" process could be put into the plugin source itself, I don't have time to do it right now but welcome any contribution that is well tested to make this the default behavior of the synthesizers.

Android Only Methods

  • getAvailableLanguages(): Promise<Array<Language>>; - returns an array of available languages (use to prevent using non-existing language/local codes)

Credits

Inspired by James Montemagno's TextToSpeech Xamarin plugin

Thanks to anarchicknight for this plugin. Thanks to stefalda for his great work on pause/resume and the finishedCallback events 💣

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].