Skip to content

Latest commit

 

History

History
93 lines (71 loc) · 2.72 KB

README.md

File metadata and controls

93 lines (71 loc) · 2.72 KB

🎙️ react-native-voicekit

VoiceKit is a powerful speech recognition library for React Native that enables voice transcription across platforms. It provides direct access to native speech recognition APIs for optimal performance and aligns the API behavior between the different platforms.

npm bundle size GitHub GitHub last commit

Warning

This project is still considered unstable and under active development. The API might change drastically in new versions. Please proceed with caution.

  • ⚡ Real-time speech-to-text transcription
  • 📱 iOS and Android support using native speech recognition APIs
  • 🧪 Fully compatible with Expo
  • ⚡ iOS and Android APIs aligned for consistent behavior and superior developer experience
  • 🎛️ Single and continuous recognition modes
  • 🎨 Simple and intuitive React Hooks API
  • 💪 TypeScript support out of the box
  • 👌 Lightweight with zero dependencies

Installation

React Native

npm install react-native-voicekit
cd ios && pod install

Expo

npx expo install react-native-voicekit

Afterwards, add the config plugin to the plugins section of your app.json:

{
  "plugins": [
    [
      "react-native-voicekit",
      {
        "speechRecognitionPermission": "Custom iOS speech recognition permission message (optional)",
        "microphonePermission": "Custom iOS microphone permission message (optional)"
      }
    ]
  ]
}

Finally, expo prebuild or rebuild your development client.

Quick Start

import React from 'react';
import { View, Text, Button } from 'react-native';
import { useVoice, VoiceMode } from 'react-native-voicekit';

const App = () => {
  const { available, listening, transcript, startListening, stopListening } = useVoice({
    locale: 'en-US',
    mode: VoiceMode.Continuous,
    enablePartialResults: true,
  });

  return (
    <View>
      {available ? (
        <>
          <Text>Is listening: {listening ? 'Yes' : 'No'}</Text>
          <Text>Transcript: {transcript}</Text>
          <Button onPress={startListening} title="Start Listening" />
          <Button onPress={stopListening} title="Stop Listening" />
        </>
      ) : (
        <Text>Speech recognition is not available on this device.</Text>
      )}
    </View>
  );
};

Documentation

A documentation is work in progress.

Contributing

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

License

MIT