0.2.4 • Published 4 years ago
xfyun-nls v0.2.4
XFYun NLS
讯飞云智能语音处理 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>
textstring - 要转换的文本。optionsXFYunTTS.BusinessOption (optional) - 合成设置。
返回值 Promise<XFYunTTS.TTSComplete> - 转换完成对象。
定义
XFYunTTS.BusinessOption
合成语言的业务参数,有如下参数:
ttestring - 文本编码格式。auxstring - 音频编码。vcnstring - 发音人。
更多请看定义 BusinessOption。
XFYunTTS.TTSComplete
合成结果对象,有如下属性:
filePathstring - 音频文件最终保存路径。suffixstring - 文件后缀。rootPathstring - 所在父文件夹路径。textstring - 合成的原文本。optionsXFYunTTS.BusinessOption - 合成的高级选项。startTimenumber - 合成任务开始的时间戳(毫秒)。elapsednumber - 合成所耗费的时间(毫秒)。
更多请看定义 TTSComplete。
Author
| funnyzak |
参考
License
Apache-2.0 License © 2021 funnyzak