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
29
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

Capacitor plugin for synthesizing speech from text.

  • 0.2.2-dev.65a0c9f
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
decreased by-14.58%
Maintainers
29
Weekly downloads
 
Created
Source


Text to Speech

@capacitor-community/text-to-speech

Capacitor community plugin for synthesizing speech from text.


Maintainers

MaintainerGitHubSocial
Robin Genzrobingenz@robin_genz

Installation

npm install @capacitor-community/text-to-speech
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/text-to-speech';

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

const { TextToSpeech } = Plugins;

/**
 * Platform: Android/iOS/Web
 * 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())
 *        speechRate - speech rate (1.0 is the normal speech rate, lower values slow down the speech, greater values accelerate it)
 *        pitchRate - pitch rate (1.0 is the normal pitch rate, smaller value lowers the tone and greater value increases it)
 *        volume - volume of the synthesis (0 - 1)
 *        voice - index of the voice (can be obtained by calling getSupportedVoices()) (Android/Web Only)
 * @returns void
 */
TextToSpeech.speak({
  text: 'This is a sample text.',
  locale: 'en_US',
  speechRate: 1.0,
  pitchRate: 1,
  volume: 1.0,
  voice: 10,
  category: 'ambient',
});

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

/**
 * Platform: Android/iOS/Web
 * This method will return list of supported languages.
 * @param none
 * @returns languages - list of available languages
 */
TextToSpeech.getSupportedLanguages();

/**
 * Platform: Android/iOS/Web
 * This method will return list of supported voices.
 * @param none
 * @returns voices - list of available voices
 */
TextToSpeech.getSupportedVoices();

/**
 * Platform: Android/iOS
 * 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();

/**
 * * Platform: Android/iOS
 * 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,
});

/**
 * * Platform: Android/iOS
 * 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,
});

Changelog

See CHANGELOG.md.

License

See LICENSE.

Keywords

FAQs

Package last updated on 12 Mar 2021

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