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

ynos-speech-recognition

v1.0.3

Published

语音识别

Downloads

3

Readme

ynos-speech-recognition

语音识别功能

安装

NPM

npm install ynos-speech-recognition --save

Yarn

yarn add ynos-speech-recognition

Bower

bower install ynos-speech-recognition --save

Development Setup

# install dependencies
npm install

# build dist files
npm run build

使用

import { YSpeechRecognition } from 'ynos-speech-recognition';

const recognition = new YSpeechRecognition();

// YSpeechRecognition接口的lang属性返回并设置当前YSpeechRecognition的语言。如果未指定,则默认为HTML语言属性值,如果未设置,则默认为用户代理的语言设置。
recognition.lang = 'cmn-Hans-CN' // 国语/普通话
// recognition.lang = 'zh-CN'  // 粤语/香港
// recognition.lang = 'en-US' // 英语/美国

// `onResult`属性表示一个事件处理程序,当语音识别服务返回一个结果时,该事件处理程序将运行 一个单词或短语已被正确识别,并已传回应用程序。
recognition.onResult = (text: string) => {
console.log(text, "响应的文字");
};

// `onSoundstart`属性表示一个事件处理程序,该处理程序将在检测到任何可识别语音或非可识别语音时运行。
recognition.onSoundstart = () => {
console.log("开始收听");
};

// `onSpeechstart`属性表示当检测到语音识别服务识别为语音的声音时,将运行的事件处理程序。
recognition.onSpeechstart = () => {
// console.log("+++");
};

// `onSpeechend`属性表示当语音识别服务识别的语音停止检测时, 将运行的事件处理程序。
recognition.onSpeechend = () => {
console.log("停止");
};

// 当发生语音识别错误时,将触发`YSpeechRecognition`对象的错误事件。
recognition.onError = (event: any) => {
console.log(event.error === "not-allowed" ? "暂无麦克风权限" : "网络受到限制!...");
};

API

属性

continuous

  • 配置设置以使每次识别都返回连续结果 默认:true。

interimResults

  • 配置应返回临时结果的设置 默认:true。

lang

  • 语言 默认使用当前计算机语言 cmn-Hans-CN.普通话 默认:zh-CN。

maxAlternatives

  • 此属性设置YSpeechRecognition.Alternative每个结果的最大数量。默认值:1。

方法

abort()

  • abort方法阻止语音识别服务侦听传入的音频,并且不会尝试返回YSpeechRecognitionResult

start()

  • 开始语音识别。

stop()

  • 结束语音识别。

onAudioend()

  • 当用户代理完成捕获语音以进行语音识别时,将触发语音API的onAudioend事件。

onAudiostart()

  • 当用户代理开始捕获音频以进行语音识别时,会触发语音API的onAudiostart事件。

onEnd()

  • 当语音识别服务断开连接时,将触发语音API YSpeechRecognition对象的结束事件。

onError()

  • 当发生语音识别错误时,将触发YSpeechRecognition对象的错误事件。

onNomatch()

  • 当语音识别服务返回没有显著识别的最终结果时,会触发语音API的onNomatch事件。

onResult(text:string)

  • onResult属性表示一个事件处理程序,当语音识别服务返回一个结果时,该事件处理程序将运行 一个单词或短语已被正确识别,并已传回应用程序。

onSoundend()

  • 语音API的onSoundend事件在停止检测任何声音(无论是否可识别语音)时触发。

soundstart()

  • onSoundstart属性表示一个事件处理程序,该处理程序将在检测到任何可识别语音或非可识别语音时运行。

onSpeechend()

  • onSpeechend属性表示当语音识别服务识别的语音停止检测时, 将运行的事件处理程序。

onSpeechstart()

  • onSpeechstart属性表示当检测到语音识别服务识别为语音的声音时,将运行的事件处理程序。

onStart()

  • 当语音识别服务开始侦听传入音频以识别与当前语音识别相关的语法时,将触发语音API YSpeechRecognition对象的启动事件。