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

@tyrchen/xftts

v0.1.1

Published

Xunfei tts websocket interface

Downloads

4

Readme

Xunfei TTS

This small buggy library is to support websocket interface of Xunfei TTS. It is only used for my pet projects, not scalable, nor robust. Use it at your own risk.

Usage

yarn add @tyrchen/xftts

Once you have added the package into your project, you could use it like this:

const { TTS } = require('@tyrchen/xftts');

const env = process.env;
const app = env.APP || '1';
const appId = env[`XF_TTS_ID${app}`];
const apiSecret = env[`XF_TTS_SECRET${app}`];
const apiKey = env[`XF_TTS_KEY${app}`];
const filename = '/tmp/test.mp3';
const text = `作为一门面向对象的语言,dart 支持 mixin,泛型等高阶功能。dart 采用了 async/await 的并发模型,
每个 future 对象可以看做是一个独立的 coroutine。dart 虽然是静态类型,但它的类型模式和 TypeScript 很类似,
类型声明虽然推荐但不强制。这几天使用下来,觉得 dart 做服务端开发似乎也不错,至少语言的表达能力要比 nodejs 背后的
javascript 强。当然,目前使用 dart 的程序员几乎都是 flutter 程序员,但不排除未来会有类似 javascript -> nodejs
这样的前端逆袭后端的事情发生。毕竟,后端程序员的能力不断地被云服务商压扁,一个后台工程师辛辛苦苦攒的服务端代码,分分钟被
firebase 这样的怪兽逆袭。`;

async function main() {
    try {
        const tts = new TTS(appId, apiKey, apiSecret, { speed: 70 });
        await tts.generate(text, filename);
        console.log('generated: ', filename);
        process.exit(0);
    } catch (error) {
        console.error(error);
        process.exit(0);
    }
}

main()

You could find the API id, key and secret from Xunfei web console. Note that the websocket protocol has a max size 8k of the payload, so make sure you split your text if the source is too long.