Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor-community/text-to-speech

Package Overview
Dependencies
Maintainers
7
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/text-to-speech

A native plugin for text to speech engine

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6K
decreased by-6.39%
Maintainers
7
Weekly downloads
 
Created
Source

Capacitor Text to Speech Plugin

Capacitory community plugin for text to speech engine.

Maintainers

MaintainerGitHubSocialSponsoring Company
Priyank PatelpriyankpatN/AIonic

Mainteinance Status: Actively Maintained

Installation

To use npm

npm install @capacitor/text-to-speech

To use yarn

yarn add @capacitor/text-to-speech

Sync native files

npx cap sync

On iOS, no further steps are needed.

On Android, register the plugin in your main activity:

import com.getcapacitor.community.tts.TextToSpeech;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(TextToSpeech.class);
    }});
  }
}

Configuration

No configuration required for this plugin.

Supported methods

NameAndroidiOSWeb
speak
stop
getSupportedLanguages
openInstall
setPitchRate
setSpeechRate

Usage

// Must import the package once to make sure the web support initializes
import '@capacitor-community/http';

import { Plugins } from '@capacitor/core';

const { TextToSpeech } = Plugins;

/**
 * This method will trigger text to speech engine and play desired text.
 * @param text - desired text to play in speech
 *        locale - supported locale (can be obtained by calling getSupportedLanguages())
 *        rate - speech rate (1.0 is the normal speech rate, lower values slow down the speech, greater values accelerate it)
 * @returns void
 */
TextToSpeech.speak({
  text: 'This is a sample text.',
  locale: 'en_US',
  rate: 1.0,
});

/**
 * This method will stop the engine if it's in the middle of playback.
 * @param none
 * @returns void
 */
TextToSpeech.stop();

/**
 * This method will return list of supported languages.
 * @param none
 * @returns void
 */
TextToSpeech.getSupportedLanguages();

/**
 * This method will trigger the platform TextToSpeech engine to start the activity that installs the resource files on the device that are required for TTS to be operational.
 * @param none
 * @returns void
 */
TextToSpeech.openInstall();

/**
 * This method will change the pitch rate while the text is being played.
 * @param pitchRate - rate of the pitch (1.0 is the normal pitch, lower values lower the tone of the synthesized voice, greater values increase it)
 * @returns void
 */
TextToSpeech.setPitchRate({
  pitchRate: 1.5
});

/**
 * This method will change the speech rate while the text is being played.
 * @param speechRate - speech rate (1.0 is the normal speech rate, lower values slow down the speech, greater values accelerate it)
 * @returns void
 */
TextToSpeech.setSpeechRate({
  speechRate: 0.5,
});

Keywords

FAQs

Package last updated on 23 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc