
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
react-native-voice2text
Advanced tools
React Native module for Android that converts speech to text using native speech recognition
react-native-voice2text is a lightweight, modern, and easy-to-use React Native native module for Android that transforms spoken words into text using the device's built-in speech recognition services. Perfect for adding voice commands, accessibility features, or hands-free inputs to your app with a clean and intuitive API.
β
Compatible with React Native 0.70+
π§ iOS support in development
npm install react-native-voice2text
# or
yarn add react-native-voice2text
For React Native >= 0.60, autolinking handles the setup automatically. For older versions or if autolinking fails, follow the manual linking steps below.
android/settings.gradle
Add the following to include the module:
include ':react-native-voice2text'
project(':react-native-voice2text').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-voice2text/android')
android/app/build.gradle
Add the module as a dependency:
dependencies {
implementation project(':react-native-voice2text')
}
MainApplication.java
Open android/app/src/main/java/<your-package>/MainApplication.java
and add the Voice2TextPackage
:
import com.voice2text.Voice2TextPackage;
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new Voice2TextPackage() // Add this
);
}
Ensure the following permissions are included in android/app/src/main/AndroidManifest.xml
:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
Here's a quick example to get you started with voice recognition:
import Voice2Text from 'react-native-voice2text';
async function startRecognition() {
try {
const granted = await Voice2Text.checkPermissions();
if (granted) {
Voice2Text.startListening('en-US');
} else {
console.warn('Microphone permission denied');
// Prompt user to enable permissions
}
} catch (error) {
console.error('Permission error:', error);
}
}
// Listen for recognized text
Voice2Text.onResults(result => {
console.log('Recognized Text:', result.text);
});
// Handle errors
Voice2Text.onError(error => {
console.error('Recognition Error:', error.message);
});
// Stop listening
Voice2Text.stopListening();
Method | Description |
---|---|
checkPermissions(): Promise<boolean> | Checks and requests microphone permission. |
startListening(locale: string) | Starts voice recognition with the specified locale (e.g., 'en-US' ). |
stopListening() | Stops the active voice recognition session. |
onResults(callback: (result: { text: string }) => void) | Subscribes to recognition result events. |
onError(callback: (error: { message: string }) => void) | Subscribes to error events. |
Ensure your native files are organized as follows:
android/app/src/main/java/com/<your-app>/voice2text/
βββ Voice2TextModule.java
βββ Voice2TextPackage.java
Maintained by Gokulkrishna
MIT Β© 2025
FAQs
React Native module for Android that converts speech to text using native speech recognition
The npm package react-native-voice2text receives a total of 19 weekly downloads. As such, react-native-voice2text popularity was classified as not popular.
We found that react-native-voice2text demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnamβs Telegram ban.