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

xunfeisdk

v1.0.1

Published

科大讯飞 WebAPI 的非官方 NodeJS 版 SDK

Downloads

13

Readme

xunfeisdk

科大讯飞 Web API 的 NodeJS 版封装。

Build Status npm version Open Source Helpers Known Vulnerabilities GitHub stars GitHub license

NPM

特点

  • TypeScript 源代码, 带 .d.ts 类型定义。 可方便的用于 TS 或者 NodeJS项目中。
  • Promise 型方法,支持 async / await 语句访问。

安装

npm install xunfeisdk

or

git clone https://github.com/breakstring/xunfeisdk.git
cd xunfeisdk
npm install

官方 WebAPI 接口

http://doc.xfyun.cn/rest_api/

测试

cd test
cp config_template.ts config.ts
# 修改你的 AppID 和各个 AppKey
# 别忘了去加你的IP地址到控制台的白名单
npm run test

使用

import * as Xunfei from "xunfeisdk";
import { IATAueType, IATEngineType, ISEAueType, ISECategoryType, ISELanguageType, ISEResultLevelType, TTSAueType, TTSAufType, TTSEngineType, TTSVoiceName } from "xunfeisdk";



const client = new Xunfei.Client("Your AppID");
// 语音评测服务(根据基准文字给语音朗读打分)
client.ISEAppKey = "语音评测的 AppKey";
const audio = fs.readFileSync(path.join(__dirname, "评测文件.wav"));
try {
    const result = await client.ISE(audio, "基准文字", ISEAueType.RAW, ISELanguageType.EN, ISECategoryType.SENTENCE, ISEResultLevelType.COMPLETE);

} catch (error) {
    // Oops...
}


// 语音听写(即语音转换为文字)
client.IATAppKey = “语音听写服务的 AppKey”;
const audio = fs.readFileSync(path.join(__dirname, "要转换为文字的音频.wav"));
try{
    const result = await client.IAT(audio, IATEngineType.SMS16K_English, IATAueType.RAW);
} catch (error) {
    // Oops...
}

// 语音合成 (即根据文字来生成音频)
client.TTSAppKey = "语音合成服务的 AppKey";
try {
    const result = await client.TTS("科大讯飞的接口文档写的太烂了", TTSAufType.L16_8K, TTSAueType.LAME, TTSVoiceName.XiaoYan);
    const mp3 = path.join(__dirname, "要存成的文件.mp3");
    fs.writeFileSync(mp3, result.audio, "binary");
} catch (error) {
    // Oops...
}