JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q76515F
  • License Apache 2.0

a xfyun nls node module.

Package Exports

  • xfyun-nls
  • xfyun-nls/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xfyun-nls) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

XFYun NLS

js-standard-style action license NPM version npm download

讯飞云智能语音处理 Node 模块。

目录

开始

from npm

$ npm install xfyun-nls

在线语音合成

用例

const { XFYunTTS } = require('xfyun-nls');
const path = require('path');
const fs = require('fs');

!(async () => {
  const cachePath = path.join(process.cwd(), new Date().getTime().toString());
  fs.mkdirSync(cachePath);

  const _xfyTTS = new XFYunTTS(
    {
      appId: '5e3b7ffe',
      apiSecret: '8440c6f3dc6e3b864a043dbb6c37afd0',
      apiKey: '1394021f9ef53a9a9400b4d8a5f4652a',
      host: 'tts-api.xfyun.cn',
      uri: '/v2/tts',
      hostUrl: 'wss://tts-api.xfyun.cn/v2/tts'
    } /** XFYunTTS.Config **/,
    cachePath /** catchPath (optional) **/
  );

  // send
  console.log('TTS COMPLETE:', JSON.stringify(await _xfyTTS.send('你好')));
  // more ...
})();

了解更多 TTS Define.

函数

XFYunTTS 有如下方法:

checkConfig(): Promise<boolean>

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

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

send(text: string, options?: XFYunTTS.BusinessOption): Promise<XFYunTTS.TTSComplete>

  • text string - 要转换的文本。
  • options XFYunTTS.BusinessOption (optional) - 合成设置。

返回值 Promise<XFYunTTS.TTSComplete> - 转换完成对象。

定义

XFYunTTS.BusinessOption

合成语言的业务参数,有如下参数:

  • tte string - 文本编码格式。
  • aux string - 音频编码。
  • vcn string - 发音人。

更多请看定义 BusinessOption

官方文档参考

XFYunTTS.TTSComplete

合成结果对象,有如下属性:

  • filePath string - 音频文件最终保存路径。
  • suffix string - 文件后缀。
  • rootPath string - 所在父文件夹路径。
  • text string - 合成的原文本。
  • options XFYunTTS.BusinessOption - 合成的高级选项。
  • startTime number - 合成任务开始的时间戳(毫秒)。
  • elapsed number - 合成所耗费的时间(毫秒)。

更多请看定义 TTSComplete

Author

twitter/funnyzak
funnyzak

参考

License

Apache-2.0 License © 2021 funnyzak