background_stt
Um plugin Flutter para serviço de fala para texto e texto para fala sempre ativo em modo de fundo.
Um plugin Flutter para executar um serviço de fala para texto sempre ativo em segundo plano.
{"sdk":"flutter"}{"sdk":"flutter"}Texto original em inglês. Visite o GitHub para a versão atual.
An flutter plugin that runs Speech-to-Text continously in background. This plugin operates in 2 modes:
Voice commands will be recognized in background and sent to Flutter app.
Voice commands will be recognized and if confirmation was requested for the command, confirmation flow will begin. Once user has provided with "Positive" or "Negative" reply, confirmation mode will end delivering voice input results to flutter app.
Speech results will be delivered in real-time to the flutter app.
Demo
In your pubspec.yaml
dependencies:
background_stt: [LATEST_VERSION]
import 'package:background_stt/background_stt.dart';
Note: Service will keep on running once it is started and can only be stopped by calling stop service method.
var _service = BackgroundStt();
_service.startSpeechListenService;
_service.getSpeechResults().onData((data) {
print("getSpeechResults: ${data.result} , ${data.isPartial}");
});
This can be useful for simple decisions.
_service.getSpeechResults().onData((data) {
if (command == "start") {
_service.confirmIntent(
confirmationText: "Do you want to start?",
positiveCommand: "yes",
negativeCommand: "no");
}
});
_service.getConfirmationResults().onData((data) {
print(
"getConfirmationResults: Confirmation Text: ${data.confirmationIntent} , "
"User Replied: ${data.confirmedResult} , "
"Is Confirmation Success?: ${data.isSuccess}");
});
This can be useful for taking voice input from user and then confirming that input from user by voice command verification.
_service.getSpeechResults().onData((data) {
if (command == "address") {
_service.confirmIntent(
confirmationText: "What is the address?",
positiveCommand: "yes",
negativeCommand: "no",
voiceInputMessage: "Is the address correct?",
voiceInput: true);
}
});
_service.getConfirmationResults().onData((data) {
print(
"getConfirmationResults: Confirmation Text: ${data.confirmationIntent} , "
"User Replied: ${data.confirmedResult} , "
"Voice Input Message: ${data.voiceInput} , "
"Is Confirmation Success?: ${data.isSuccess}");
});
await _service.cancelConfirmation;
_service.stopSpeechListenService;
await _service.pauseListening();
await _service.resumeListening();
If you want to queue voice messages, send queue value 'true':
await _service.speak("Hello",true)
To interupt and speak current playing message, send queue value 'false':
await _service.speak("Hello",false)
Set speaker pitch and speech rate:
_service.setSpeaker(0.2, 0.5)
background_stt plugin is developed by Umair Adil. You can email me at <m.umair.adil@gmail.com> for any queries.