SpeechToTextProvider class
Simplifies interaction with SpeechToText by handling all the callbacks and notifying listeners as events happen.
Here's an example of using the SpeechToTextProvider
var speechProvider = SpeechToTextProvider( SpeechToText());
var available = await speechProvider.initialize();
StreamSubscription<SpeechRecognitionEvent> _subscription;
_subscription = speechProvider.stream.listen((recognitionEvent) {
if (recognitionEvent.eventType == SpeechRecognitionEventType.finalRecognitionEvent ) {
print("I heard: ${recognitionEvent.recognitionResult.recognizedWords}");
}
});
speechProvider.addListener(() {
var words = speechProvider.lastWords;
});
- Inheritance
-
- Object
- ChangeNotifier
- SpeechToTextProvider
Constructors
- SpeechToTextProvider(SpeechToText _speechToText)
- Only construct one instance in an application.
Properties
- hasError → bool
-
Returns true if SpeechToText has a previous error.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- hasResults → bool
-
Returns true if lastResult has a last result.
no setter
- isAvailable → bool
-
Returns true if the provider has been initialized and can be used to recognize speech.
no setter
- isListening → bool
-
Returns true if SpeechToText is listening for new speech.
no setter
- isNotAvailable → bool
-
Returns true if the provider cannot be used to recognize speech, either because it has not
yet been initialized or because initialization failed.
no setter
- isNotListening → bool
-
Returns true if SpeechToText is not listening for new speech.
no setter
- lastError → SpeechRecognitionError?
-
Returns the last error received.
no setter
- lastLevel → double
-
Returns the last sound level received.
no setter
- lastResult → SpeechRecognitionResult?
-
Returns the last result received.
no setter
-
locales
→ List<
LocaleName> -
Returns the list of locales that are available on the device for speech recognition.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
SpeechRecognitionEvent> -
no setter
- systemLocale → LocaleName?
-
Returns the locale that is currently set as active on the device.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
cancel(
) → void - Cancel a current active listening session.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
initialize(
{dynamic debugLogging = false, Duration finalTimeout = SpeechToText.defaultFinalTimeout, List< SpeechConfigOption> ? options}) → Future<bool> - Initializes the provider and the contained SpeechToText instance.
-
listen(
{bool partialResults = true, dynamic onDevice = false, bool soundLevel = false, Duration? listenFor, Duration? pauseFor, String? localeId, ListenMode listenMode = ListenMode.confirmation}) → void -
Start listening for new events, set
partialResults
to true to receive interim recognition results. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
stop(
) → void - Stops a current active listening session.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited