搜索插件、代码仓与 APP 分类

插件详情v1.0.6

background_stt

一个用于语音转文本和文本转语音服务的 Flutter 插件,可在后台模式下始终运行。

AndroidiOS
近 30 天下载
94
喜欢数
40
Pub 分数
140

安装插件

flutter pub add background_stt

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 插件,可在 Android 和 iOS 上实现后台持续的语音转文本(STT)和文本转语音(TTS)功能。专为语音助手设计,即使应用处于非活动状态,也能实现实时转录和音频输出。该插件可持久运行服务,非常适合需要持续监听或响应的免提应用。它可无缝集成到 Flutter 项目中,并通过原生代码支持两种平台的特定实现。

适合场景

  • 语音控制的应用程序
  • 始终开启的助手功能
  • 免提数据输入
  • 导航过程中的实时转录
  • 背景音频反馈

主要特点

  • 连续后台运行
  • 跨平台支持(Android 和 iOS)
  • 内置的语音识别和语音合成服务
  • 所需用户交互最少
  • 原生服务集成

适合对象

  • 开发语音助手的开发者
  • 需要持续语音输入的应用程序
  • 带有语音命令的无障碍工具
  • 带有语音输入功能的生产力应用
  • 智能家居控制界面

使用建议

  • 由于后台处理导致电池消耗过高
  • 两个平台都需要正确的权限
  • 可能无法在所有设备制造商上一致工作
  • 对系统级音频路由的控制有限
  • 始终监听功能可能带来的隐私担忧

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。