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

react-native-android-voice-persian

v0.6.2

Published

A React Native Voice Recognition Module With Persian Locale support

Downloads

7

Readme

react-native-android-voice

react-native-android-voice is a speech-to-text library for React Native for the Android Platform with Persian locale support.

##Any Feedback and Ideas are welcome! please use the Issues section above

Documentation

Install

npm install --save react-native-android-voice-persian
yarn add react-native-android-voice-persian

Usage

Linking the Library

Add it to your android project

  • In android/settings.gradle
...
include ':VoiceModule', ':app'
project(':VoiceModule').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-voice-persian')
  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':VoiceModule')
}
  • Register Module (in MainApplication.java)
import com.wmjmc.reactspeech.VoicePackage;  // <--- import

public class MainApplication extends Application implements ReactApplication {
...
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new VoicePackage()); // <--- added here
    }
}

Example

import SpeechAndroid from 'react-native-android-voice-persian';

...
async _buttonClick(){
    try{
        //More Locales will be available upon release.
        var spokenText = await SpeechAndroid.startSpeech("Speak yo", SpeechAndroid.GERMAN);
        ToastAndroid.show(spokenText , ToastAndroid.LONG);
    }catch(error){
        switch(error){
            case SpeechAndroid.E_VOICE_CANCELLED:
                ToastAndroid.show("Voice Recognizer cancelled" , ToastAndroid.LONG);
                break;
            case SpeechAndroid.E_NO_MATCH:
                ToastAndroid.show("No match for what you said" , ToastAndroid.LONG);
                break;
            case SpeechAndroid.E_SERVER_ERROR:
                ToastAndroid.show("Google Server Error" , ToastAndroid.LONG);
                break;
            /*And more errors that will be documented on Docs upon release*/
        }
    }
}
...

This will automatically start recognizing and adjusting for the German Language. On release I'll update these docs with every single Locale available.

Methods

startSpeech(prompt, locale)

Initializes the voice recognition activity and returns what you spoke in text.

Arguments

  • prompt: String for the text to be displayed by the SpeechRecognizer dialog;
  • locale: String for the SpeechRecognizer to set itself for the given Locale; (Accessible through constants. see below available locales)

Locales:

DEFAULT

SpeechAndroid.DEFAULT

This will set the SpeechRecognizer to the default locale of your Android smartphone.


Portugal / Portuguese

SpeechAndroid.PT /*or*/ SpeechAndroid.PORTUGUESE

Brazil / Portuguese

SpeechAndroid.BR /*or*/ SpeechAndroid.PORTUGUESE_BRAZIL

Bulgarian

SpeechAndroid.BULGARIAN

Canada / English

SpeechAndroid.CANADA

Canada / French

SpeechAndroid.CANADA_FRENCH

Czech

SpeechAndroid.CZECH

Croatian

SpeechAndroid.CROATIAN

Chinese

SpeechAndroid.CHINA /*or*/ SpeechAndroid.CHINESE /*or*/
SpeechAndroid.SIMPLIFIED_CHINESE /*or*/ SpeechAndroid.TRADITIONAL_CHINESE

Netherlands / Dutch

SpeechAndroid.DUTCH

Belgium / Dutch

SpeechAndroid.DUTCH_BELGIUM

English

SpeechAndroid.ENGLISH

UK / English

SpeechAndroid.UK

US / English

SpeechAndroid.US

Australia / English

SpeechAndroid.AUSTRALIA

New Zealand / English

SpeechAndroid.NEW_ZEALAND

Singapore / English

SpeechAndroid.SINGAPORE

India / English

SpeechAndroid.ENGLISH_INDIA

Ireland / English

SpeechAndroid.ENGLISH_IRELAND

Zimbabwe / English

SpeechAndroid.ENGLISH_ZIMBABWE

Egypt / Arabic

SpeechAndroid.ARABIC_EGYPT

Israel / Arabic

SpeechAndroid.ARABIC_ISRAEL

France / French

SpeechAndroid.FRANCE /*or*/ SpeechAndroid.FRENCH

Belgium / French

SpeechAndroid.FRENCH_BELGIUM

Switzerland / French

SpeechAndroid.FRENCH_SWITZERLAND

Finnish

SpeechAndroid.FINNISH

Danish

SpeechAndroid.DANISH

Germany / German

SpeechAndroid.GERMANY /*or*/ SpeechAndroid.GERMAN

Switzerland / German

SpeechAndroid.GERMAN_SWITZERLAND

Greek

SpeechAndroid.GREEK

Hebrew

SpeechAndroid.HEBREW

Hindi

SpeechAndroid.HINDI

Hungarian

SpeechAndroid.HUNGARIAN

Italy / Italian

SpeechAndroid.ITALY /*or*/ SpeechAndroid.ITALIAN

Switzerland / Italian

SpeechAndroid.ITALIAN_SWITZERLAND

Indonesian

SpeechAndroid.INDONESIAN

Latvian

SpeechAndroid.LATVIAN

Lithuanian

SpeechAndroid.LITHUANIAN

Norwegian

SpeechAndroid.NORWEGIAN

Japan

SpeechAndroid.JAPAN /*or*/ SpeechAndroid.JAPANESE

Polish

SpeechAndroid.POLISH

Persian

SpeechAndroid.PERSIAN

Russian

SpeechAndroid.RUSSIAN

Romanian

SpeechAndroid.ROMANIAN

Spanish

SpeechAndroid.SPANISH

Catalan

SpeechAndroid.CATALAN

US / Spanish

SpeechAndroid.SPANISH_US

Serbian

SpeechAndroid.SERBIAN

Slovak

SpeechAndroid.SLOVAK

Slovenian

SpeechAndroid.SLOVENIAN

Swedish

SpeechAndroid.SWEDISH

Korea

SpeechAndroid.KOREA /*or*/ SpeechAndroid.KOREAN

Taiwan

SpeechAndroid.TAIWAN

Philippines / Tagalog

SpeechAndroid.TAGALOG_PHILIPPINES

Thai

SpeechAndroid.THAI

Turkish

SpeechAndroid.TURKISH

Ukrainian

SpeechAndroid.UKRAINIAN

Vietnamese

SpeechAndroid.VIETNAMESE

Errors

E_ACTIVITY_DOES_NOT_EXIST

SpeechAndroid.E_ACTIVITY_DOES_NOT_EXIST

Generic error on current Activity not existing.


E_VOICE_CANCELLED

SpeechAndroid.E_VOICE_CANCELLED

Voice Recognizer was cancelled


E_FAILED_TO_SHOW_VOICE

SpeechAndroid.E_FAILED_TO_SHOW_VOICE

Voice Recognizer failed to initialize


E_AUDIO_ERROR

SpeechAndroid.E_AUDIO_ERROR

Voice Recognizer encountered some error with the Audio received


E_NETWORK_ERROR

SpeechAndroid.E_NETWORK_ERROR

Network error while attempting connection with Google's Servers


E_NO_MATCH

SpeechAndroid.E_NO_MATCH

Voice Recognizer did not find any match


E_SERVER_ERROR

SpeechAndroid.E_SERVER_ERROR

Google's Servers encountered an error while processing the request