SpeechToText class Null safety

An interface to device specific speech recognition services.

The general flow of a speech recognition session is as follows:

SpeechToText speech = SpeechToText();
bool isReady = await speech.initialize();
if ( isReady ) {
  await speech.listen( resultListener: resultListener );
}
...
// At some point later
speech.stop();

Constructors

SpeechToText()
factory
SpeechToText.withMethodChannel()

Properties

errorListener SpeechErrorListener?
read / write
hasError bool
True if an error has been received, see lastError for details
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
hasPermission Future<bool>
Returns true if the user has already granted permission to access the microphone, does not prompt the user. [...]
read-only
hasRecognized bool
True if words have been recognized during the current listen call. [...]
read-only
isAvailable bool
True if initialize succeeded
read-only
isListening bool
True if listen succeeded and stop or cancel has not been called. [...]
read-only
isNotListening bool
read-only
lastError SpeechRecognitionError?
The last error received or null if none, see initialize to register an optional listener to be notified of errors.
read-only
lastRecognizedWords String
The last set of recognized words received. [...]
read-only
lastSoundLevel double
The last sound level received during a listen event. [...]
read-only
lastStatus String
The last status update received, see initialize to register an optional listener to be notified when this changes.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
statusListener SpeechStatusListener?
read / write

Methods

cancel() Future<void>
Cancels the current listen for speech if active, does nothing if not. [...]
initialize({SpeechErrorListener? onError, SpeechStatusListener? onStatus, dynamic debugLogging = false, Duration finalTimeout = _defaultFinalTimeout, List<SpeechConfigOption>? options}) Future<bool>
Initialize speech recognition services, returns true if successful, false if failed. [...]
listen({SpeechResultListener? onResult, Duration? listenFor, Duration? pauseFor, String? localeId, SpeechSoundLevelChange? onSoundLevelChange, dynamic cancelOnError = false, dynamic partialResults = true, dynamic onDevice = false, ListenMode listenMode = ListenMode.confirmation, dynamic sampleRate = 0}) Future
Starts a listening session for speech and converts it to text, invoking the provided onResult method as words are recognized. [...]
locales() Future<List<LocaleName>>
returns the list of speech locales available on the device. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
stop() Future<void>
Stops the current listen for speech if active, does nothing if not. [...]
systemLocale() Future<LocaleName?>
returns the locale that will be used if no localeId is passed to the listen method.
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Properties

androidAlwaysUseStop SpeechConfigOption
final
androidIntentLookup SpeechConfigOption
final

Constants

listeningStatus → const String
'listening'
listenMethod → const String
'listen'
notifyErrorMethod → const String
'notifyError'
notifyStatusMethod → const String
'notifyStatus'
notListeningStatus → const String
'notListening'
soundLevelChangeMethod → const String
'soundLevelChange'
textRecognitionMethod → const String
'textRecognition'