SpeechRecognizer Class

Definition

This class provides access to the speech recognition service.

[Android.Runtime.Register("android/speech/SpeechRecognizer", DoNotGenerateAcw=true)]
public class SpeechRecognizer : Java.Lang.Object
[<Android.Runtime.Register("android/speech/SpeechRecognizer", DoNotGenerateAcw=true)>]
type SpeechRecognizer = class
    inherit Object
Inheritance
SpeechRecognizer
Attributes

Remarks

This class provides access to the speech recognition service. This service allows access to the speech recognizer. Do not instantiate this class directly, instead, call SpeechRecognizer#createSpeechRecognizer(Context), or SpeechRecognizer#createOnDeviceSpeechRecognizer(Context). This class's methods must be invoked only from the main application thread.

<strong>Important:</strong> the caller MUST invoke #destroy() on a SpeechRecognizer object when it is no longer needed.

The implementation of this API is likely to stream audio to remote servers to perform speech recognition. As such this API is not intended to be used for continuous recognition, which would consume a significant amount of battery and bandwidth.

Please note that the application must have android.Manifest.permission#RECORD_AUDIO permission to use this class.

Java documentation for android.speech.SpeechRecognizer.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Name Description
SpeechRecognizer(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

Name Description
ConfidenceScores

Key used to retrieve a float array from the Bundle passed to the RecognitionListener#onResults(Bundle) and RecognitionListener#onPartialResults(Bundle) methods.

DetectedLanguage

Key used to retrieve a String representation of the IETF language tag (as defined by BCP 47, e.

ErrorAudio
Obsolete.

Audio recording error.

ErrorCannotCheckSupport
Obsolete.

The service does not allow to check for support.

ErrorCannotListenToDownloadEvents
Obsolete.

The service does not support listening to model downloads events.

ErrorClient
Obsolete.

Other client side errors.

ErrorInsufficientPermissions
Obsolete.

Insufficient permissions

ErrorLanguageNotSupported
Obsolete.

Requested language is not available to be used with the current recognizer.

ErrorLanguageUnavailable
Obsolete.

Requested language is supported, but not available currently (e.

ErrorNetwork
Obsolete.

Other network related errors.

ErrorNetworkTimeout
Obsolete.

Network operation timed out.

ErrorNoMatch
Obsolete.

No recognition result matched.

ErrorRecognizerBusy
Obsolete.

RecognitionService busy.

ErrorServer
Obsolete.

Server sends error status.

ErrorServerDisconnected
Obsolete.

Server has been disconnected, e.

ErrorSpeechTimeout
Obsolete.

No speech input

ErrorTooManyRequests
Obsolete.

Too many requests from the same client.

LanguageDetectionConfidenceLevel

Key used to retrieve the level of confidence of the detected language of the most recent audio chunk, represented by an int value prefixed by LANGUAGE_DETECTION_CONFIDENCE_LEVEL_.

LanguageDetectionConfidenceLevelConfident
LanguageDetectionConfidenceLevelHighlyConfident
LanguageDetectionConfidenceLevelNotConfident
LanguageDetectionConfidenceLevelUnknown
LanguageSwitchResult

Key used to retrieve the result of the language switch of the most recent audio chunk, represented by an int value prefixed by LANGUAGE_SWITCH_.

LanguageSwitchResultFailed
Obsolete.

Switch attempted and failed.

LanguageSwitchResultNotAttempted
Obsolete.

Switch not attempted.

LanguageSwitchResultSkippedNoModel
Obsolete.

Switch skipped because the language model is missing or the language is not allowlisted for auto switch.

LanguageSwitchResultSucceeded
Obsolete.

Switch attempted and succeeded.

RecognitionParts

Key used to receive an ArrayList&lt;RecognitionPart&gt; object from the Bundle passed to the RecognitionListener#onResults(Bundle) and RecognitionListener#onSegmentResults(Bundle) methods.

ResultsAlternatives

Key used to retrieve an ArrayList&lt;AlternativeSpans&gt; from the Bundle passed to the RecognitionListener#onResults(Bundle) and RecognitionListener#onPartialResults(Bundle) methods.

ResultsRecognition

Key used to retrieve an ArrayList<String> from the Bundle passed to the RecognitionListener#onResults(Bundle) and RecognitionListener#onPartialResults(Bundle) methods.

TopLocaleAlternatives

Key used to retrieve an ArrayList&lt;String&gt; containing representations of the IETF language tags (as defined by BCP 47, e.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers
PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Name Description
Cancel()

Cancels the speech recognition.

CheckRecognitionSupport(Intent, IExecutor, IRecognitionSupportCallback)

Checks whether recognizerIntent is supported by SpeechRecognizer#startListening(Intent).

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
CreateOnDeviceSpeechRecognizer(Context)

Factory method to create a new SpeechRecognizer.

CreateSpeechRecognizer(Context, ComponentName)

Factory method to create a new SpeechRecognizer.

CreateSpeechRecognizer(Context)

Factory method to create a new SpeechRecognizer.

Destroy()

Destroys the SpeechRecognizer object.

Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
Equals(Object) (Inherited from JavaObject)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
IsOnDeviceRecognitionAvailable(Context)

Checks whether an on-device speech recognition service is available on the system.

IsRecognitionAvailable(Context)

Checks whether a speech recognition service is available on the system.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
SetRecognitionListener(IRecognitionListener)

Sets the listener that will receive all the callbacks.

StartListening(Intent)

Starts listening for speech.

StopListening()

Stops listening for speech.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
TriggerModelDownload(Intent, IExecutor, IModelDownloadListener)

Attempts to download the support for the given recognizerIntent.

TriggerModelDownload(Intent)

Attempts to download the support for the given recognizerIntent.

UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Events

Name Description
BeginningOfSpeech

The user has started to speak.

BufferReceived

More sound has been received.

EndOfSegmentedSession

Called at the end of a segmented recognition request.

EndOfSpeech

Called after the user stops speaking.

Error

A network or recognition error occurred.

Event

Reserved for adding future events.

LanguageDetection

Called when language detection and switching results are available.

PartialResults

Called when partial recognition results are available.

ReadyForSpeech

Called when the endpointer is ready for the user to start speaking.

Results

Called when recognition results are ready.

RmsChanged

The sound level in the audio stream has changed.

SegmentResults

Called for each ready segment of a recognition request.

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to