Search packages, repositories and app categories

Package detailsv1.0.6

background_stt

A flutter plugin for Speech-to-Text & Text-To-Speech service always active in background mode.

AndroidiOS
30-day downloads
85
Likes
40
Pub points
140

Install package

flutter pub add background_stt

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter plugin enabling continuous Speech-to-Text (STT) and Text-to-Speech (TTS) functionality in the background on Android and iOS. Designed for voice assistants, it allows real-time transcription and audio output even when the app is inactive. The plugin runs services persistently, making it ideal for hands-free applications that require constant listening or response. It integrates seamlessly with Flutter projects and supports both platform-specific implementations through native code.

Use cases

  • Voice-controlled apps
  • Always-on assistant features
  • Hands-free data entry
  • Real-time transcription during navigation
  • Background audio feedback

Key features

  • Continuous background operation
  • Cross-platform support (Android & iOS)
  • Built-in STT and TTS services
  • Minimal user interaction required
  • Native service integration

Suitable for

  • Developers building voice assistants
  • Apps requiring persistent voice input
  • Accessibility tools with voice commands
  • Productivity apps with voice input
  • Smart home control interfaces

Considerations

  • High battery usage due to background processing
  • Requires proper permissions on both platforms
  • May not work consistently on all device manufacturers
  • Limited control over system-level audio routing
  • Potential privacy concerns with always-listening features

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

background_stt

Speech-to-Text, Text-to-speech, Interactive Voice commands
[Android Support Only]

pub package

An flutter plugin that runs Speech-to-Text continously in background. This plugin operates in 2 modes:

1. STT Mode

Voice commands will be recognized in background and sent to Flutter app.

2. Confirmation Mode

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

Install

In your pubspec.yaml

dependencies:
  background_stt: [LATEST_VERSION]
import 'package:background_stt/background_stt.dart';

How to use it?

Start Speech-to-Text Service

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}");
    });
Setup Intent for Simple Confirmation

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}");
    });
Setup Intent for Voice-Input Confirmation

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}");
    });
Cancel Confirmation in progress

  await _service.cancelConfirmation;
Stop Speech-to-Text Service

  _service.stopSpeechListenService;
Pause Speech-to-Text Listener

  await _service.pauseListening();
Resume Speech-to-Text Listener

  await _service.resumeListening();
Speak Text and Interupt Listener

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)

Author

background_stt plugin is developed by Umair Adil. You can email me at <m.umair.adil@gmail.com> for any queries.

Categories

Source repository

Projects using this package

No data available yet.