搜尋套件、儲存庫與 APP 分類

套件詳情v1.1.12

flutter_audio_capture

透過麥克風捕獲音訊緩衝串流,適用於 iOS/Android。

AndroidiOSLinux
近 30 天下載
1150
喜歡數
34
Pub 分數
130

安裝套件

flutter pub add flutter_audio_capture

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

flutter_audio_capture 是一個 Flutter 插件,可在 Android、iOS 和 Linux 上實現設備麥克風的即時音訊錄製。它提供對原始音訊緩衝區串流的存取,適用於需要低階音訊處理的應用程式,例如語音分析、即時音訊效果或自訂音訊流程。該套件與 Flutter 的事件驅動架構無縫整合,並支援可設定取樣率和頻道數的連續音訊串流。非常適合需要直接控制音訊輸入的音訊導向應用程式開發者。

適用情境

  • 即時語音處理
  • 音頻可視化
  • 語音控制的應用程式
  • 即時音頻串流
  • 自定音效

主要特色

  • 原始音訊緩衝區串流存取
  • 跨平台支援(Android、iOS、Linux)
  • 可設定的取樣率和通道
  • 低延遲音頻捕獲
  • 事件驅動串流 API

適合對象

  • 音頻分析工具
  • 語音辨識系統
  • 音樂製作應用
  • 互動音頻體驗
  • 即時通訊應用

使用建議

  • 需要麥克風權限
  • 可能消耗大量電池電量
  • 持續捕獲期間CPU使用率過高
  • 有限的文件
  • 需要平台特定的設定

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_audio_capture

Capture the audio stream buffer through microphone for iOS/Android. Required OS version is iOS 13+ or Android 23+

Getting Started

Add this line to your pubspec.yaml file:

dependencies:
  flutter_audio_capture: ^1.1.12

and execute

$ flutter pub get
Android

If you want to use this package on Android OS, you need to set RECORD_AUDIO permission to AndroindManifest.xml like below.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.ymd.flutter_audio_capture">
  ...
  // Add this line
  <uses-permission android:name="android.permission.RECORD_AUDIO"/>
</manifest>
iOS

If you want to use this package on iOS, you need to set NSMicrophoneUsageDescription to Info.plist like below.

<dict>
    <key>NSMicrophoneUsageDescription</key>
    <string>Need microphone access to capture audio</string>
...
Linux

On Linux, this package uses parec to record audio.

While things should just work on recent Ubuntu versions, make sure to have pulseaudio installed on the target device.

Example

You can see full example in example/lib/main.dart

import 'package:flutter_audio_capture/flutter_audio_capture.dart';
...

// Callback function if device capture new audio stream.
// argument is audio stream buffer captured through mictophone.
// Currentry, you can only get is as Float64List.
void listener(dynamic obj) {
  var buffer = Float64List.fromList(obj.cast<double>());
  print(buffer);
}

// Callback function if flutter_audio_capture failure to register
// audio capture stream subscription.
void onError(Object e) {
  print(e);
}

...

FlutterAudioCapture plugin = new FlutterAudioCapture();

// Initialize the plugin (required before start)
await plugin.init();

// Start to capture audio stream buffer
// sampleRate: sample rate you want
// bufferSize: buffer size you want (iOS only)
await plugin.start(listener, onError, sampleRate: 16000, bufferSize: 3000);

// Stop to capture audio stream buffer
await plugin.stop();

所屬分類

原始碼儲存庫

使用此套件的專案