javascript - 使用文字转语音消息发起呼叫
问题描述
我为 NodeJs 使用 Asterisk-Manager 包
https://www.npmjs.com/package/asterisk-manager
并有一个磁带公告作为文本,必须通过文本翻译成语音。当我尝试拨打拨出电话号码时,如何设置文本到语音变量和收件人?一个例子是
ami.action({
'action': 'originate',
'??? phonenumber ???': '12345',
'??? text to be spoken ???': 'Hello, this is a tape announcement'
}, (err, res) => {
if (err) {
throw err;
}
console.log('everything was fine');
});
编辑:
我知道 FreePbx 用于管理。据我所知,Asterisk 引擎有一个 TTS 模块。
我想我可以去这个代码
const { phoneNumber, announcement } = phoneInfo; // the required data
ami.action({
channel: `SIP/${phoneNumber}`,
application: 'SendText',
data: announcement
}, (err, res) => {
if (err) {
throw err;
}
console.log(res);
});
引擎将管理数据属性
解决方案
Originate 应用程序本身只会将被叫号码发送到应用程序或分机。您应该在调用播放应用程序之前创建一个音频文件。因此,您的代码将如下所示:
let filePath = await yourTtsService.generateAudioFile('Hello, this is a tape announcement')
ami.action({
'action': 'originate',
'channel': 'SIP/123', // target number, depend on your trunk type
'application': 'Playback',
'data': filePath
})
要生成音频文件,您可以使用 google api,请参阅https://cloud.google.com/text-to-speech/docs/reference/libraries中的示例
推荐阅读
- r - 使用 RShiny 部署简单的线性回归模型
- typescript - 在单独的文件上定义 Typescript 模块类型
- mysql - 如何在 MySQL 中将月份与 min bal 一起显示为列
- c# - 如何在 ASP.NET CORE 中更新模型
- visual-studio-code - VS Code 自动保存文件历史/撤消
- java - 如何在android studio中获得可用尺寸的屏幕尺寸?
- r - R STUDIO:我无法读取 .csv 中的 Ü 等特殊字符
- mysql - 用 if else 语句更新 mysqli 中的一行
- python - 将装饰器应用于 Python 类
- html - 我的描述文字没有响应,但输入的文字效果很好