/speechrecognition

Easy to use cross platform speech recognition (speech to text) plugin for Xamarin & UWP

Primary LanguageC#MIT LicenseMIT

ACR Speech Recognition Plugin for Xamarin & Windows

Easy to use cross platform speech recognition (speech to text) plugin for Xamarin & UWP

NuGet NuGet

PLATFORMS

  • iOS 10+
  • Android
  • Windows UWP

SETUP

iOS Add the following to your NSSpeechRecognitionUsageDescription
Say something useful here
NSMicrophoneUsageDescription
Say something useful here

Android

Add the following to your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

UWP

Add the following to your app manifest
<Capabilities>
	<Capability Name="internetClient" />
	<DeviceCapability Name="microphone" />
</Capabilities>

HOW TO USE

Request Permission

var granted = await SpeechRecognizer.Instance.RequestPermission();
if (granted) 
{
    // go!
}

Easy Use

SpeechRecognizer.Instance.Listen().Subscribe(x => 
{
	// you will get each individual word the user speaks here
});

Listen for a phrase (good for a web search)

SpeechRecognizer
    .Instance
    .Listen(true) // passing true will complete this observable when the end of speech is detected
    .Subscribe(phrase => {})

Stop the thing!

var token = SpeechRecognizer.Instance.Listen().Subscribe(...);
token.Dispose(); // call this whenever you're done and it will clean up after itself!

When can I talk?

SpeechRecognizer.Instance.WhenListenStatusChanged().Subscribe(isListening => { you can talk if this is true });

Speech Dialogs Addin

Speech dialogs is an additional nuget you can install via nuget to add easy question based prompts. It will prompt the user with questions using Text-to-Speech and you can reply with a selection of answers

Confirm

var answer = await SpeechDialogs.Instance.Confirm("Are you sure you want to do this?", "yes", "no");

Prompt (great for searches)

var prompt = await SpeechDialogs.Instance.Prompt("How was your day?");

Actions

SpeechDialogs.Instance.Actions(new ActionsConfig("Choose your destiny!") 
    .Choice("Fatalitiy", () => 
    { 
        // do something here
    })
    .Choice("Friendship", () => 
    {
    
    })
    .SetShowActionSheet(true) // this will decide if you also want to include the UI dialog
    .SetSpeakChoices(true)    // this will read the choices out that you make available
)

FAQ

Q. Why use reactive extensions and not async?

A. Speech is very event stream oriented which fits well with RX

Q. Should I use SpeechRecognizer.Instance?

A. Hell NO! DI that sucker using the Instance

Roadmap

  • Multilingual
  • Confidence Scoring
  • Mac Support
  • Start and end of speech eventing
  • RMS detection