SpeechToText class
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?
-
getter/setter pair
- hasError → bool
-
True if an error has been received, see lastError for details
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
hasPermission
→ Future<
bool> -
Returns true if the user has already granted permission to access the
microphone, does not prompt the user.
no setter
- hasRecognized → bool
-
True if words have been recognized during the current listen call.
no setter
- isAvailable → bool
-
True if initialize succeeded
no setter
- isListening → bool
-
True if listen succeeded and stop or cancel has not been called.
no setter
- isNotListening → bool
-
no setter
- lastError → SpeechRecognitionError?
-
The last error received or null if none, see initialize to
register an optional listener to be notified of errors.
no setter
- lastRecognizedWords → String
-
The last set of recognized words received.
no setter
- lastSoundLevel → double
-
The last sound level received during a listen event.
no setter
- lastStatus → String
-
The last status update received, see initialize to register
an optional listener to be notified when this changes.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusListener ↔ SpeechStatusListener?
-
getter/setter pair
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 nonexistent 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
- listenMethod → const String
- notifyErrorMethod → const String
- notifyStatusMethod → const String
- notListeningStatus → const String
- soundLevelChangeMethod → const String
- textRecognitionMethod → const String