
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-native-speechkit
Advanced tools
A powerful React Native library for real-time speech recognition with audio recording and playback capabilities for iOS and Android
🎤 A powerful React Native library for real-time speech recognition, audio recording, and playback on iOS and Android.
npm install react-native-speechkit
# or
yarn add react-native-speechkit
cd ios && pod install
Info.plist:
NSMicrophoneUsageDescriptionNSSpeechRecognitionUsageDescriptionRECORD_AUDIO permission is already in AndroidManifest.xml.import { PermissionsAndroid, Platform } from 'react-native';
async function requestMicrophonePermission() {
if (Platform.OS === 'android') {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
{
title: 'Microphone Permission',
message:
'This app needs access to your microphone for speech recognition.',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
}
);
return granted === PermissionsAndroid.RESULTS.GRANTED;
}
return true;
}
import {
startSpeechRecognition,
stopSpeechRecognition,
addSpeechResultListener,
addSpeechErrorListener,
addSpeechFinishedListener,
playAudio,
} from 'react-native-speechkit';
// Start speech recognition (optionally pass fileURLString and autoStopAfter in ms)
await startSpeechRecognition();
// Listen for results (partial and final)
const resultSub = addSpeechResultListener(({ text, isFinal }) => {
console.log('Transcribed:', text, 'Final:', isFinal);
});
// Listen for errors
const errorSub = addSpeechErrorListener(({ error }) => {
console.error('Error:', error);
});
// Listen for finished event (final result and audio path)
const finishedSub = addSpeechFinishedListener(({ finalResult, audioLocalPath }) => {
console.log('Final result:', finalResult, 'Audio file:', audioLocalPath);
// Play the recorded audio
if (audioLocalPath) {
playAudio(audioLocalPath);
}
});
### `playAudio(filePath: string): Promise<string>`
Play an audio file at the given path (local file or URL). Returns a promise that resolves when playback starts.
// Stop recognition
stopSpeechRecognition();
// Remove listeners when done
resultSub.remove();
errorSub.remove();
finishedSub.remove();
startSpeechRecognition(fileURLString?: string | null, autoStopAfter?: number | null): Promise<string>Start speech recognition and audio recording. Optionally specify a file path and auto-stop duration (ms).
stopSpeechRecognition(): voidStop the current recognition session.
addSpeechResultListener(listener: (data: { text: string; isFinal: boolean }) => void)Subscribe to speech recognition results (partial and final). Returns a subscription with .remove().
addSpeechErrorListener(listener: (data: { error: string }) => void)Subscribe to errors. Returns a subscription with .remove().
addSpeechFinishedListener(listener: (data: { finalResult: string; audioLocalPath: string }) => void)Subscribe to the finished event, which provides the final recognized text and the local audio file path. Returns a subscription with .remove().
import { useState, useEffect } from 'react';
import { View, Button, Text } from 'react-native';
import {
startSpeechRecognition,
stopSpeechRecognition,
addSpeechResultListener,
addSpeechErrorListener,
addSpeechFinishedListener,
playAudio,
} from 'react-native-speechkit';
export default function App() {
const [isRecording, setIsRecording] = useState(false);
const [text, setText] = useState('');
const [audioPath, setAudioPath] = useState('');
useEffect(() => {
const resultSub = addSpeechResultListener(({ text, isFinal }) => {
setText(text + (isFinal ? ' (final)' : ''));
});
const errorSub = addSpeechErrorListener(() => setIsRecording(false));
const finishedSub = addSpeechFinishedListener(
({ finalResult, audioLocalPath }) => {
setText(finalResult);
setAudioPath(audioLocalPath);
setIsRecording(false);
}
);
return () => {
resultSub.remove();
errorSub.remove();
finishedSub.remove();
};
}, []);
return (
<View>
<Text>{text || 'No text yet'}</Text>
<Text>{audioPath ? `Audio: ${audioPath}` : ''}</Text>
<Button
title={isRecording ? 'Stop' : 'Start'}
onPress={
isRecording
? () => {
stopSpeechRecognition();
setIsRecording(false);
}
: async () => {
await startSpeechRecognition();
setIsRecording(true);
}
}
/>
{audioPath ? (
<Button title="Play Audio" onPress={() => playAudio(audioPath)} />
) : null}
</View>
);
}
Contributions are welcome! Please read the Contributing Guide and Code of Conduct.
MIT © ChasonJia
FAQs
A powerful React Native library for real-time speech recognition with audio recording and playback capabilities for iOS and Android
We found that react-native-speechkit 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.