
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
rn-text-to-speech
Advanced tools
This module provides text-to-speech functionality for Android and iOS platforms in React Native applications.
To install this module, you can use npm or yarn:
npm install rn-text-to-speech
or
yarn add rn-text-to-speech
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);
});
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;
This module is licensed under the MIT License. See the LICENSE file for details.
FAQs
text-to-speech for Android and iOS
The npm package rn-text-to-speech receives a total of 2 weekly downloads. As such, rn-text-to-speech popularity was classified as not popular.
We found that rn-text-to-speech demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.