@fugood/react-native-audio-pcm-stream

中文文档
1.1.4发布于 2023/03/23MITCommonJS零依赖近 30 天下载 13.9万

Get audio PCM stream data for React Native

原始使用文档
文档目录7 节
  1. Install
  2. Add Microphone Permissions
  3. iOS
  4. Android
  5. Usage
  6. Credits/References
  7. License

react-native-live-audio-stream

npm

Get live audio stream data for React Native. Ideal for live voice recognition (transcribing).

This module is modified from react-native-audio-record. Instead of saving to an audio file, it only emit events with live data. By doing this, it can reduce memory usage and eliminate file operation overheads in the case that an audio file is not necessary (e.g. live transcribing).

Most of the code was written by the respective original authors.

Install

yarn add react-native-live-audio-stream
cd ios
pod install

Add Microphone Permissions

iOS

Add these lines to ios/[YOU_APP_NAME]/info.plist

<key>NSMicrophoneUsageDescription</key>
<string>We need your permission to use the microphone.</string>

Android

Add the following line to android/app/src/main/AndroidManifest.xml

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

Usage

import LiveAudioStream from 'react-native-live-audio-stream';

const options = {
  sampleRate: 32000,  // default is 44100 but 32000 is adequate for accurate voice recognition
  channels: 1,        // 1 or 2, default 1
  bitsPerSample: 16,  // 8 or 16, default 16
  audioSource: 6,     // android only (see below)
  bufferSize: 4096    // default is 2048
};

LiveAudioStream.init(options);
LiveAudioStream.on('data', data => {
  // base64-encoded audio data chunks
});
  ...
LiveAudioStream.start();
  ...
LiveAudioStream.stop();
  ...

audioSource should be one of the constant values from here. Default value is 6 (VOICE_RECOGNITION).

Use 3rd-party modules like buffer to decode base64 data. Example:

// yarn add buffer
import { Buffer } from 'buffer';
  ...
LiveAudioStream.on('data', data => {
  var chunk = Buffer.from(data, 'base64');
});

Credits/References

License

MIT

版本与发布记录

@fugood/react-native-audio-pcm-stream 共发布 3 个版本,首次发布于 2023/03/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.4latest2023/03/233 年前
1.1.32023/03/233 年前
1.1.22023/03/233 年前

关于 @fugood/react-native-audio-pcm-stream 的常见问题

@fugood/react-native-audio-pcm-stream 是什么?

Get audio PCM stream data for React Native

如何安装 @fugood/react-native-audio-pcm-stream?

在项目目录运行 npm install @fugood/react-native-audio-pcm-stream,或使用 pnpm add / yarn add / bun add。

@fugood/react-native-audio-pcm-stream 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fugood__react-native-audio-pcm-stream 是否存在。

@fugood/react-native-audio-pcm-stream 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fugood/react-native-audio-pcm-stream 可以商用吗?

@fugood/react-native-audio-pcm-stream 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fugood/react-native-audio-pcm-stream 的下载量有多少?

根据 npm 官方下载统计,@fugood/react-native-audio-pcm-stream 在 2026/10/16 – 2026/11/14 这 30 天内被下载 138,852 次,日均约 4,628 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fugood/react-native-audio-pcm-stream 还在维护吗?

最新版本 1.1.4 发布于 2023/03/23(3 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/03/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。