npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fetaoily/xfyun-iat-rtasr-sdk

v1.0.3

Published

## 前置步骤

Downloads

1

Readme

文档

前置步骤

  1. 将dist目录下processor.worker.jsprocessor.worklet.js复制到项目目录中,使其可以通过浏览器地址栏访问,
  2. 浏览器录音权限需要在localhost、127.0.0.1或https下

RecorderManager

浏览器录音管理器

方法

RecorderManager.constructor(processorPath)

构造函数

processorPathprocessor.worker.jsprocessor.worklet.js的路径地址,如果访问地址/a/b/c/processor.worker.js,则processorPath为/a/b/c

RecorderManager.start(Object object)

开始录音

Object object

| 属性 | 类型 | 默认值 | 必填 | 取值范围 | 说明 | | ------ | ------ | ------ | ------ | ------ | ------ | | sampleRate | number | 浏览器默认采样率 | 否 | 8000 ~ 96000 | 采样率 | | frameSize | number | - | 否 | >0 | 指定帧大小,传入 frameSize 后,每录制指定帧大小的内容后,会回调录制的文件内容,不指定则不会回调。ps:在不支持设置采样率的浏览器下,录音分片数据会比此处设置的值大 | | arrayBufferType | string | - | 否 | "short16" "float32" | 音频数据ArrayBuffer类型 |

RecorderManager.stop()

停止录音

调用stop后,还需要等待浏览器处理完已经录制的音频后才会真正结束,需要在停止录音成功后做的处理请在.onStop回调中处理

RecorderManager.onStart = function listener

监听录音开始事件

RecorderManager.onStop = function listener

监听录音结束事件

const listener = (audioBuffers: ArrayBuffer[]) => {}

| 属性 | 类型 | 说明 | | ------ | ------ | ------ | | audioBuffers | ArrayBuffer[] | 录音分片数据数组 |

RecorderManager.onFrameRecorded = function listener

监听已录制完指定帧大小的文件事件。如果设置了 frameSize,则会回调此事件。

const listener = ({isLastFrame, frameBuffer} : {
  isLastFrame: boolean;
  frameBuffer: ArrayBuffer;
}) => {}

| 属性 | 类型 | 说明 | | ------ | ------ | ------ | | isLastFrame | boolean | 当前帧是否正常录音结束前的最后一帧 | | frameSize | ArrayBuffer | 录音分片数据 |

示例代码

const recorder = new RecorderManager ("../../dist");

recorder.onFrameRecorded = ({ isLastFrame, frameBuffer }) => {
  console.log(isLastFrame, frameBuffer)
};
recorder.onStop = (audioBuffers) => {
  console.log(audioBuffers)
}


recorder.start({
  sampleRate: 16000,
  frameSize: 1280,
});

setTimeout(() => {
  recorder.stop()
}, 60000)

听写示例

查看example/iat 将example/iat/index.html下面的值替换成真实的值

  var APPID = "xxx";
  var API_SECRET = "xxx";
  var API_KEY = "xxx";

实时语音转写

查看example/rtasr 将example/rtasr/index.html下面的值替换成真实的值

  var APPID = "xxx";
  var API_KEY = "xxx";

运行

  1. 安装 npm install -g http-server
  2. 运行 http-server .
  3. 浏览器打开听写示例:http://127.0.0.1:xxx/example/iat/index.html
  4. 浏览器打开实时语音转写示例:http://127.0.0.1:xxx/example/rtasr/index.html