open-index/open-npm huggingface dataset:
npm package: @goldnet/speech
Description: 在网页上使用语音识别，并且脱机工作， 实时的监听麦克风输入，并转换所需音频文件及文字。
Author: yangxiao
Latest version: 0.0.3

## speech 

在网页上使用语音识别，并且脱机工作， 实时的监听麦克风输入，并转换所需音频文件及文字。

## 安装

```
npm i @goldnet/speech --save
```

## 导入

``` ts
import { Speech } from '@goldnet/speech';
```

## 使用

```js
const speech = new Speech();

speech.on('start', onStart);
speech.on('end', onEnd);
speech.on('error', onError);
speech.on('result', onResult);

let allowed = false;

function start(){
    speech.getUserMediaAllowed().then(value => {
        allowed = value;
    });

    if (allowed) {
        speech.start();
    }
}

```

## 兼容

 - PC Chrome >= 53
 - PC Edge >= 12
 - PC Safari >= 11
 - PC Firefox >= 36
 - Android Chrome >= 109
 - iOS Safari >= 11
 - Android >= 5
 - iOS >= 11

## API 

### 获取权限

用于获取当前用户的权限设定，可以使用返回true

getUserMediaAllowed()

```ts
getUserMediaAllowed().then(value => {
        allowed = value;
});
```

### 开始录制

`start();`

### 结束录制

`stop();`

### 关闭麦克风

`closeMike()`

### 设置语言

`defaultLang = 'cmn-Hans-CN'`

### 设置超时时间

> 单位毫秒

`timeOut=30000`

### 事件

```
speech.on('start', onStart); // 录制开始
speech.on('end', onEnd); // 录制结束输出
speech.on('error', onError); // 录制异常,
speech.on('result', onResult); // 录制中的输出
speech.on('timeout', onTimeOut); // 录制超时
```

## 注意

由于录制编码问题，Android中的编码格式为webp, iOS低版本没有集成解码器， 需要iOS升级到15以上。
npm package: @goldnet/websocket
Description: ## 安装
Author: yangxiao
Latest version: 0.0.9


## 兼容Sockjs的WebSocket

## 安装

```
npm i @goldnet/websocket --save
```

## 导入

``` ts
import { H5WebSocket, type MSG } from '@goldnet/websocket';
```

## 数据格式

id与服务器协商，如果使用数据格式，可以直接监听具体的ID，如socket.on('idName', onMsg);
``` json
{id:string,body:any}
```



## WebSocket 方式

``` ts
const socket = new H5WebSocket('native');

// socket.outInfoFn = console.log;
// socket.on('open', onOpen);
// socket.on('close', onClose);
// socket.on('error', onError);
// socket.on('timeout', onTimeOut);
// socket.on('message', onMessage);
socket.connect('ws://xxxx');
// 需要服务器实现基于ID定义的消息回传
socket.send({ id: 'c_s_msg', body: { msg: 'test' } });

function onOpen(msg) {
    console.log('onOpen', msg);
}
function onClose(msg) {
    console.log('onClose', msg);
}
function onError(msg) {
    console.log('onError', msg);
}
function onTimeOut(msg) {
    console.log('onTimeOut', msg);
}
function onMessage(msg) {
    console.log('onMessage', msg);
}
function onMsg(msg) {
    console.log('onMsg', msg);
}
```

## Sockjs,Stomp 方式
``` js
import { H5WebSocket } from '@goldnet/websocket';

const socket = new H5WebSocket('sockjs');

socket.on('CONNECTED', onCONNECTED); // 连接成功，服务器定义
socket.on('MESSAGE', onMESSAGE); // 格式化后的消息，服务器定义
socket.connect('wss://xxxx'); // 连接服务器

function onCONNECTED(msg) {
    console.log('onCONNECTED', msg);

    socket.send({ id: 'SEND', headers: { destination: `/app/xxxx` }, body: {} });
    socket.send({ id: 'SUBSCRIBE', headers: { id: 'sub-0', destination: `/user/xxxx` } });
}

function onMESSAGE(msg) {
    console.log('onMESSAGE', msg);

    switch (msg.headers?.subscription) {
        case 'sub-0':
            debugger
            break;
        default:
            console.warn('onMESSAGE 异常消息', msg);
    }
}

```

可以通过属性`defaultConnectHeaders`设置连接时的头信息

## API

### 最大重连次数
    defualtMaximuRedeliveries = 2；
### 连接服务器
	connect(host: string, timeOut?: number): void;
### 发送消息
	send(msg: MSG): void;
### 关闭服务
	close(code?: number | undefined, reason?: string | undefined): void;
npm package: @goldpage/express
Description: <!---
Latest version: 0.5.13

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->

Goldpage + Express = :heart:

# `@goldpage/express`

Use Goldpage with [Express](https://github.com/expressjs/express).

### Usage

Install `@goldpage/express`.

~~~shell
$ npm install @goldpage/express
~~~

The plugin is automatically loaded and
an Express middleware is now available at `require('goldpage').express`.

### Example

~~~js
// ./example/server.js

const express = require('express');
const ssr = require('goldpage');

const app = express();

// Goldpage also has middlewares for Koa, Hapi, etc.
app.use(ssr.express);

app.listen(3000, () => {console.log('Server is running.')});
~~~

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/express/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->
npm package: @goldpage/hapi
Description: <!---
Latest version: 0.5.13

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->

Goldpage + Hapi = :heart:

# `@goldpage/hapi`

Use Goldpage with [Hapi](https://github.com/hapijs/hapi).

### Usage

Install `@goldpage/hapi`.

~~~shell
$ npm install @goldpage/hapi
~~~

The plugin is automatically loaded and
a Hapi plugin is now available at `require('goldpage').hapi`.

### Example

~~~js
// ./example/server.js

const Hapi = require('hapi');
const ssr = require('goldpage');

startServer();

async function startServer() {
  const server = Hapi.Server({
    port: process.env.PORT || 3000,
    debug: {request: ['internal']},
  });

  await server.register(ssr.hapi);

  await server.start();

  console.log('Server running');
}
~~~

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/hapi/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->
npm package: @goldpage/koa
Description: <!---
Latest version: 0.5.13

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->

Goldpage + Koa = :heart:

# `@goldpage/koa`

Use Goldpage with [Koa](https://github.com/koajs/koa).

### Usage

Install `@goldpage/koa`.

~~~shell
$ npm install @goldpage/koa
~~~

The plugin is automatically loaded and
a Koa middleware is now available at `require('goldpage').koa`.

### Example

~~~js
// ./example/server.js

const Koa = require('koa');
const ssr = require('goldpage');

const app = new Koa();

app.use(ssr.koa);

app.listen(3000, () => {console.log('Server is running')});
~~~

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/koa/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->