Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

northwesternmutual/react-native-transcribe

Repository files navigation

react-native-transcribe

library to send raw microphone data (array) for AWS Transcribe

You can use this library to send to any speech to text service, this one includes a sample AWS Lambda function for AWS Transcribe.

Usage

import Transcribe from 'react-native-transcribe';

// ...

Contributing

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

License

MIT

Get started with the project:

$ yarn bootstrap

Run the example app on iOS:

$ yarn example ios

Run the example app on Android:

$ yarn example android

iOS This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSSpeechRecognitionUsageDescription key with a string value explaining to the user how the app uses this data.

Android AndroidManifest.xml

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

Note: Special settings for mic on android (adb emu avd hostmicon) emulator -avd Pixel_3a_API_30_x86 -qemu -allow-host-audio https://developer.android.com/studio/run/emulator-commandline https://gist.github.com/wswebcreation/80f5536ab1592aff0c25a9dbd9cc1451

Running the example

Setup

In the root directory /react-native-transcribe, run

npm install

Next, change to example directory and install packages

cd /react-native-transcribe/example/
npm install

Running ios

  1. Install cocoa pods
cd /react-native-transcribe/example/ios
pod install
  1. Start react-native example project
cd /react-native-transcribe/example
npm run start
  1. Start ios Project.
    Open the TranscribeExample.xcworkspace file from ../example/ios in XCode Click Build and Run

Running Android

  1. Start react-native example project
cd /react-native-transcribe/example
npm run start
  1. Ensure your emulator command works properly. https://developer.android.com/studio/run/emulator-commandline
  2. Open Android emulator from the Terminal with the emulator command:
user@host ~ $ emulator -list-avds
Pixel_4_API_30

#emulator -avd [EMULATOR_NAME] -qemu -allow-host-audio

user@host ~ $  emulator -avd Pixel_4_API_30 -qemu -allow-host-audio
  1. Toggle (in a different terminal) the microphone ON
#adb emu avd hostmicon
user@host ~ $ adb emu avd hostmicon 
OK

** You can also use the simulator's extended menu (...) to allow headset microphones **

  1. In Android Studio, open project and naviagate to /react-native-transcribe/example/android
  2. Build

Troubleshooting Android:

If you try to start your emulator and you receive this in the terminal:

audio: Failed to create voice `dac'
coreaudio: Could not initialize record
coreaudio: Could not set samplerate 44100
coreaudio: Reason: kAudioDeviceUnsupportedFormatError
coreaudio: Could not initialize record
coreaudio: Could not set samplerate 44100
coreaudio: Reason: kAudioDeviceUnsupportedFormatError

Mac: Make sure your audio is set to your system default (MacBook Pro Speakers and MacBook Pro Microphone)