Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@picovoice/react-native-voice-processor
Advanced tools
Readme
Made in Vancouver, Canada by Picovoice
The React Native Voice Processor is an asynchronous audio capture library designed for real-time audio processing on mobile devices. Given some specifications, the library delivers frames of raw audio data to the user via listeners.
React Native Voice Processor is available via npm. To import it into your React Native project install with npm or yarn:
yarn add @picovoice/react-native-voice-processor
or
npm i @picovoice/react-native-voice-processor --save
To enable recording with the hardware's microphone, you must first ensure that you have enabled the proper permission on both iOS and Android.
On iOS, open the Info.plist
file and add the following line:
<key>NSMicrophoneUsageDescription</key>
<string>[Permission explanation]</string>
On Android, open the AndroidManifest.xml
and add the following line:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
See our example app for how to properly request this permission from your users.
Access the singleton instance of VoiceProcessor
:
import {
VoiceProcessor,
VoiceProcessorError
} from '@picovoice/react-native-voice-processor';
let voiceProcessor = VoiceProcessor.instance;
Add listeners for audio frames and errors:
voiceProcessor.addFrameListener((frame: number[]) => {
// use audio frame
});
voiceProcessor.addErrorListener((error: VoiceProcessorError) => {
// handle error
});
Ask for audio record permission and start recording with the desired frame length and audio sample rate:
const frameLength = 512;
const sampleRate = 16000;
try {
if (await voiceProcessor.hasRecordAudioPermission()) {
await voiceProcessor.start(frameLength, sampleRate);
} else {
// user did not grant permission
}
} catch (e) {
// handle start error
}
Stop audio capture:
try {
await this._voiceProcessor.stop();
} catch (e) {
// handle stop error
}
Once audio capture has started successfully, any frame listeners assigned to the VoiceProcessor
will start receiving audio frames with the given frameLength
and sampleRate
.
Any number of listeners can be added to and removed from the VoiceProcessor
instance. However,
the instance can only record audio with a single audio configuration (frameLength
and sampleRate
),
which all listeners will receive once a call to start()
has been made. To add multiple listeners:
const listener1 = (frame) => { };
const listener2 = (frame) => { };
const listeners = [listener1, listener2];
voiceProcessor.addFrameListeners(listeners);
voiceProcessor.removeFrameListeners(listeners);
// or
voiceProcessor.clearFrameListeners();
The React Native Voice Processor app demonstrates how to ask for user permissions and capture output from the VoiceProcessor
.
To launch the demo, run:
yarn bootstrap
yarn example ios
# or
yarn example android
FAQs
A library for real-time voice processing in React Native.
The npm package @picovoice/react-native-voice-processor receives a total of 62 weekly downloads. As such, @picovoice/react-native-voice-processor popularity was classified as not popular.
We found that @picovoice/react-native-voice-processor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.