npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

voice-recognition-react-native

v0.1.2

Published

voice recognition at react native

Downloads

11

Readme

voice-recognition-react-native

voice recognition at react native

The voice-recognition-react-native is a library that provides voice recognition functionality in React Native applications. This library supports voice recognition on iOS and Android.

Installation

npm install voice-recognition-react-native
yarn add voice-recognition-react-native

Setting

Ios

in ios/Podfile

(Optional)Manual Link

pod 'RNSpeechRecognition', :path => '../node_modules/voice-recognition-react-native/ios'

in Info.plist

<key>NSSpeechRecognitionUsageDescription</key>
<string>We need access to your microphone for speech recognition</string>
<key>NSMicrophoneUsageDescription</key>
<string>We need access to your microphone for speech recognition</string>

and root of terminal

cd ios
pod install
cd ..

Android

in android/app/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.RECORD_AUDIO"/>

(Optional)Manual Link in MainApplication.kt

import com.voicerecognitionreactnative.VoiceRecognitionReactNativePackage; #add this line

public class MainApplication extends Application implements ReactApplication {

  @Override
  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new VoiceRecognitionReactNativePackage() # add this line
    );
  }
}

Usage

import React, { useState, useEffect } from 'react';
import { SafeAreaView, Button, Text, View } from 'react-native';
import {
  startRecognition,
  stopRecognition,
  addRecognitionListener,
  removeRecognitionListener
} from 'voice-recognition-react-native';

const App = () => {
  const [recognizedText, setRecognizedText] = useState<string>('');
  const [isRecognizing, setIsRecognizing] = useState<boolean>(false);

  useEffect(() => {
    const handleResult = (result: string) => {
      setRecognizedText(result);
      console.log('Recognition result received: ', result);
    };

    const handleError = (error: string) => {
      console.error('Recognition error received: ', error);
      setIsRecognizing(false);
    };

    addRecognitionListener(handleResult, handleError);

    return () => {
      removeRecognitionListener();
    };
  }, []);

  const handleStartRecognition = async () => {
    try {
      console.log('Recognition started');
      setIsRecognizing(true);
      await startRecognition();
    } catch (error) {
      console.error('Recognition error: ', error);
      setIsRecognizing(false);
    }
  };

  const handleStopRecognition = () => {
    stopRecognition();
    setIsRecognizing(false);
    console.log('Recognition stopped');
  };

  return (
    <SafeAreaView style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#000' }}>
      <Button title="Start Recognition" onPress={handleStartRecognition} disabled={isRecognizing} />
      <Button title="Stop Recognition" onPress={handleStopRecognition} disabled={!isRecognizing} />
      <View style={{ padding: 10, backgroundColor: '#333', borderRadius: 5, marginTop: 20 }}>
        <Text style={{ color: '#fff', fontSize: 16 }}>
          Recognized Text: {recognizedText}
        </Text>
      </View>
    </SafeAreaView>
  );
};

export default App;

Support Api

startRecognition(): Promise Starts speech recognition. Returns a Promise that returns the recognized text.

stopRecognition(): void Stop speech recognition.

addRecognitionListener(onResult: (result: string) => void, onError: (error: string) => void): void Add listeners for speech recognition results and errors.

removeRecognitionListener(): void remove recognition listeners

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library