🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

rn-text-to-speech

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-text-to-speech

text-to-speech for Android and iOS

1.0.4
latest
Source
npm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

React Native Text to Speech

Description

This module provides text-to-speech functionality for Android and iOS platforms in React Native applications.

Installation

To install this module, you can use npm or yarn:

npm install rn-text-to-speech

or

yarn add rn-text-to-speech

Usage

Importing the module First, import the module into your React Native component:

import Tts from 'rn-text-to-speech';

Speaking text To speak text, use the speak method:

Tts.speak("Hello, world!");

Pausing and resuming speech You can pause and resume speech using the pause and resume methods:

Tts.pause();
Tts.resume();

Stopping speech To stop speech, use the stop method:

Tts.stop();

Setting voice and parameters You can set voice, rate, pitch, language, and other parameters using the appropriate methods:

Tts.setDefaultVoice(voiceId);
Tts.setDefaultRate(rate);
Tts.setDefaultPitch(pitch);
Tts.setDefaultLanguage(language);

Getting available voices You can retrieve available voices using the voices method:

Tts.voices().then((voices) => {
  console.log(voices);
});

Example

Here's an example of how you might use this module in a React Native component:

import React, { useEffect } from 'react';
import { View, Button } from 'react-native';
import Tts from 'rn-text-to-speech';

const MyComponent = () => {
  useEffect(() => {
    Tts.setDefaultLanguage('en-US');
    Tts.setDefaultRate(0.5);
  }, []);

  const speakHello = () => {
    Tts.speak('Hello, world!');
  };

  return (
    <View>
      <Button title="Speak" onPress={speakHello} />
    </View>
  );
};

export default MyComponent;

License

This module is licensed under the MIT License. See the LICENSE file for details.

Keywords

tts

FAQs

Package last updated on 26 Apr 2024

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