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

aliyun-nls

v0.3.8

Published

a aliyun nls node module.

Downloads

55

Readme

AliYun NLS

js-standard-style action license NPM version npm download

阿里云智能语音处理 Node 模块。

目录

开始

from npm

$ npm install/aliyun-nls

长文本语音合成

用例

const { AliyunTTS } = require(/aliyun-nls');

!(async () => {
  const _aliyunTTS = new AliyunTTS(
    {
      accessKeyId: 'accessKeyId',
      accessKeySecret: 'accessKeySecret',
      endpoint: 'https://nls-meta.cn-shanghai.aliyuncs.com',
      nlsUrl: 'https://nls-gateway.cn-shanghai.aliyuncs.com/rest/v1/tts/async',
      apiVersion: '2019-02-28'
    },
    'app key' /** optional **/
  );

  // test aliyun api config
  console.log((await _aliyunTTS.checkConfig()) ? 'passed' : 'error');

  // more ...
})();

了解更多 TTS Define.

函数

AliyunTTS 有如下方法:

checkConfig(): Promise<boolean>

返回值 Promise<boolean> - 返回阿里云语音配置密钥是否有效。

const checkRlt = await _aliyunTTS.checkConfig();
console.log(checkRlt ? 'the config is passed' : 'error config');

task(text: string, options?: AliyunTTS.TTSOption): Promise<string>

  • text string - 要转换的文本。
  • options NLSOption (optional) - 高级设置。
  • appKey string (optional) - 应用 key。

返回值 Promise<string> - 返回转换任务 ID。

status(taskId: string, appKey?: string): Promise<AliyunTTS.TTSComplete>

查询转换状态。

  • taskId string - 任务 ID。
  • appKey string (optional) - 应用 Key。

返回值 Promise<AliyunTTS.TTSComplete> - 转换状态。

const taskId = await _aliyunTTS.task('你好,世界!', {
  /** options **/
});

console.log(taskId);

taskSync(text: string, options: AliyunTTS.TTSOption, interval?: number): Promise<AliyunTTS.TTSComplete>;

同步返回合成结果。

  • text string - 要转换的文本。
  • options NLSOption - 高级设置。
  • interval number (optional) - 检查转换状态的轮训事件间隔(秒)。

返回值 Promise<AliyunTTS.TTSComplete> - 转换状态。

const rlt = await _aliyunTTS.taskSync('你好,世界!', {
  format: 'mp3'
  sample_rate: 16000,
  voice: 'xiaoyun',
  volume: 50,
  speech_rate: 50,
  pitch_rate: 50
  /* options */
});

console.log('complete result => ', JSON.stringify(rlt));

定义

AliyunTTS.TTSOption

  • appKey - 应用 Key,可选。
  • format - 音频编码格式,支持 pcm/wav/mp3 格式,默认是 pcm。
  • sample_rate - 音频采样率,支持 16000Hz 和 8000Hz,默认是 16000Hz。
  • voice - 发音人,默认是 xiaoyun。更多发音人请参见接口说明
  • volume - 音量,范围是 0~100,默认 50。
  • speech_rate - 语速,范围是 0-100,默认是 50。
  • pitch_rate - 语调,范围是 0-100,默认是 50。
  • enable_subtitle - 是否启用句级时间戳功能,默认值为 false。
  • enable_notify - 是否启用回调功能,默认值为 false。
  • notify_url - 回调服务的地址。当 enable_notify 取值为 true 时,本字段必填。URL 支持 HTTP/HTTPS 协议,Host 不能使用 IP 地址。

AliyunTTS.TTSComplete

  • task_id string - 任务 ID。
  • audio_address string - 合成的音频 URL。
  • notify_custom string - 回调地址。
  • sentences json - 句级时间戳对象。
  • appKey: string - 使用的 APP Key。
  • options: AliyunTTS.TTSOption - 合成选项。
  • text: string - 待合成文本。
  • startTime: number - 合成开始时间(毫秒时间戳)。
  • elapsed: number - 合成耗时(毫秒)。

Author

| twitter/funnyzak | | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | funnyzak |

参考

License

Apache-2.0 License © 2021 funnyzak