我将Asterisk-Manager软件包用于NodeJ
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);
});
引擎将管理数据属性
答案 0 :(得分:2)
始发应用程序本身只会将被叫号码发送到应用程序或分机。在调用播放应用之前,您应该已经创建了一个音频文件。因此您的代码将如下所示:
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
上的示例