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

插件详情v1.1.2

flutter_voice_processor

一个专为实时语音音频处理设计的Flutter音频录制插件。

AndroidiOS
近 30 天下载
7430
喜欢数
33
Pub 分数
150

安装插件

flutter pub add flutter_voice_processor

插件介绍

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

一个用于实时语音音频处理的 Flutter 插件,可无缝集成语音助手功能。由 picovoice.ai 开发,支持 Android 和 iOS 平台,提供低延迟的音频捕获和处理,非常适合需要对语音输入立即响应的应用程序。该包专为希望实现本地设备上的语音转文本(STT)和语音命令识别、且延迟极低、准确率高的开发者设计。它利用针对边缘设备优化的先进声学模型,确保隐私与性能,无需依赖云服务。

适合场景

  • 实时语音命令
  • 设备端语音识别
  • 语音控制应用
  • 互动式语音助手
  • 移动应用中的音频分析
  • 注重隐私的语音处理

主要特点

  • 实时音频处理
  • 设备端语音识别功能
  • 低延迟性能
  • 跨平台支持(Android、iOS)
  • 隐私保护设计
  • 与 Picovoice 唤醒词引擎的集成

适合对象

  • 开发语音功能移动应用的开发者
  • 重视用户隐私的团队
  • 需要快速响应时间的应用程序
  • 基于边缘的语音处理项目
  • 移动语音助手原型

使用建议

  • 需要理解音频流
  • 仅限Picovoice生态系统
  • 商业使用可能需要额外的许可
  • 性能取决于设备硬件
  • 不适用于大规模基于云的语音识别

原始 README

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

Flutter Voice Processor

GitHub release GitHub

Pub Version

Made in Vancouver, Canada by Picovoice

Twitter URL

YouTube Channel Views

The Flutter Voice Processor is an asynchronous audio capture library designed for real-time audio processing on mobile devices. Given some specifications, the library delivers frames of raw audio data (16-bit, mono PCM) to the user via listeners.

Table of Contents

Requirements

Compatibility

  • Flutter 1.20.0+
  • Android 5.0+ (API 21+)
  • iOS 13.0+

Installation

Flutter Voice Processor is available via pub.dev. To import it into your Flutter project, add the following line to your pubspec.yaml:

dependencies:
  flutter_voice_processor: ^<version>

Permissions

To enable recording with the hardware's microphone, you must first ensure that you have enabled the proper permission on both iOS and Android.

On iOS, open the Info.plist file and add the following line:

<key>NSMicrophoneUsageDescription</key>
<string>[Permission explanation]</string>

On Android, open the AndroidManifest.xml and add the following line:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

See our example app for how to properly request this permission from your users.

Usage

Access the singleton instance of VoiceProcessor:

import 'package:flutter_voice_processor/flutter_voice_processor.dart';

VoiceProcessor? _voiceProcessor = VoiceProcessor.instance;

Add listeners for audio frames and errors:

VoiceProcessorFrameListener frameListener = (List<int> frame) {
    // use audio
}

VoiceProcessorErrorListener errorListener = (VoiceProcessorException error) {
    // handle error
}

_voiceProcessor?.addFrameListener(frameListener);
_voiceProcessor?.addErrorListener(errorListener);

Ask for audio record permission and start recording with the desired frame length and audio sample rate:

final int frameLength = 512;
final int sampleRate = 16000;
if (await _voiceProcessor?.hasRecordAudioPermission() ?? false) {
    try {
        await _voiceProcessor?.start(frameLength, sampleRate);
    } on PlatformException catch (ex) {
        // handle start error
    }
} else {
    // user did not grant permission
}

Stop audio capture:

try {
    await _voiceProcessor?.stop();
} on PlatformException catch (ex) {
    // handle stop error
}

Once audio capture has started successfully, any frame listeners assigned to the VoiceProcessor will start receiving audio frames with the given frameLength and sampleRate.

Capturing with Multiple Listeners

Any number of listeners can be added to and removed from the VoiceProcessor instance. However, the instance can only record audio with a single audio configuration (frameLength and sampleRate), which all listeners will receive once a call to start() has been made. To add multiple listeners:

VoiceProcessorFrameListener listener1 = (frame) { }
VoiceProcessorFrameListener listener2 = (frame) { }
List<VoiceProcessorFrameListener> listeners = [listener1, listener2];
_voiceProcessor?.addFrameListeners(listeners);

_voiceProcessor?.removeFrameListeners(listeners);
// or
_voiceProcessor?.clearFrameListeners();

Example

The Flutter Voice Processor app demonstrates how to ask for user permissions and capture output from the VoiceProcessor.

Releases

v1.1.0 - August 4, 2023
  • Numerous API improvements
  • Error handling improvements
  • Allow for multiple listeners instead of a single callback function
  • Upgrades to testing infrastructure and example app
v1.0.0 - December 8, 2020
  • Initial public release.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。