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

套件詳情v0.7.2

mic_stream

一個用於從裝置麥克風接收原始字節串流的外掛。音訊以 `Stream` 形式回傳。

AndroidiOSmacOS
近 30 天下載
725
喜歡數
99
Pub 分數
130

安裝套件

flutter pub add mic_stream

套件介紹

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

mic_stream 套件提供了一種簡單的方法,使用 Dart Stream 訪問設備麥克風的原始音訊資料。它支援在 Android、iOS 和 macOS 上進行即時音訊捕捉,非常適合需要底層音訊處理的應用程式,例如語音辨識、聲音視覺化或即時音訊分析。此外,該外掛直接提供音訊位元組,讓開發者可依需求處理編碼、過濾或傳輸。僅需透過 Flutter pub add 進行最少設定,即可順暢整合至現有專案。

適用情境

  • 即時語音處理
  • 音頻可視化
  • 語音控制的應用程式
  • 即時音頻串流
  • 聲音分析

主要特色

  • 原始位元組流輸出
  • 跨平台支援(Android、iOS、macOS)
  • 即時音訊捕捉
  • 簡單的流式 API
  • 輕量且依賴極少

適合對象

  • 開發音訊分析工具的開發者
  • 需要低延遲麥克風輸入的應用程式
  • 涉及自定義音頻處理的項目
  • 原型設計語音功能
  • 移動音頻應用

使用建議

  • 所有平台都需要麥克風權限
  • 僅限原始位元組資料(無內建解碼)
  • 可能需要額外的音訊格式處理
  • 性能取決於設備功能
  • 某些平台可能限制背景音效

原始 README

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

mic_stream: 0.7.2

[Flutter Plugin] Provides a tool to get the microphone input as 8 or 16 bit PCM Stream. 32 bit and floating point PCM are experimental WIP.

About mic_stream:

As Flutter still lacks some functionality, this plugin aims to provide the possibility to easily get an audio stream from the microphone of mobile devices.

How to use:

The plugin mainly provides one method to provide a raw audio stream:

Stream<UInt8List> MicStream.microphone({options})

and a StreamTransformer to provide a Stream of individual samples (not lists of samples):

MicStream.toSampleStream

that you can use to transform your mic stream:

stream.transform(MicStream.toSampleStream)

Listening to this stream starts the audio recorder while cancelling the subscription stops the stream.

Available options are as follows:

audioSource: AudioSource      // The microphone you want to record from
sampleRate: int               // The amount of data points to record per second
channelConfig: ChannelConfig  // Mono or Stereo
audioFormat: AudioFormat      // 8 bit PCM or 16 bit PCM. Other formats are not yet supported

Some configuration options are platform dependent and can differ from the originally configured ones. You can check the real values using:

Future<int> sampleRate = await MicStream.sampleRate;
Future<int> bitDepth = await MicStream.bitDepth;
Future<int> bufferSize = await MicStream.bufferSize;
Permissions

Make sure you have microphone recording permissions enabled for your project. To do so, add this line to the AndroidManifest.xml:

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

In the Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>Microphone access required</string>

You can disable the permission request dialogue by calling MicStream.shouldRequestPermission(false) This will lead to an error if no permission to record audio has been requested, though.

For MacOS:

Open macos/Runner.xcworkspace click Runner -> Signing & Capabilities -> Check "Audio Input"

Example:
// Init a new Stream
Stream<List<int>> stream = await MicStream.microphone(sampleRate: 44100);

// Start listening to the stream
StreamSubscription<List<int>> listener = stream.listen((samples) => print(samples));
// Transform the stream and print each sample individually
stream.transform(MicStream.toSampleStream).listen(print);
// Cancel the subscription
listener.cancel()

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。