2

I use the Asterisk-Manager package for NodeJs

https://www.npmjs.com/package/asterisk-manager

and have a tape announcement as a text which must be translated via text to speech. When I try to call an outgoing phone number how can I setup the text to speech variable and the recipient? An example would be

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');
  });

Edit:

I know that FreePbx is used for administration. As far as I know there is a TTS module for the Asterisk engine.

I think I could go for this code

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);
});

and the engine would manage the data property

  • Look like asterisk-manager is "just" a wrapper around [Asterisk 11 Manager API](https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+AMI+Actions), so you would need to find a way from there, and use it. I'd say you would need to find a way to trigger [Asterisk Application Playback](https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Playback) and select your pre recorded speech, but I don't have the time to dig in the specifics. – DrakaSAN Feb 25 '19 at 16:52

1 Answers1

1

The Originate application itself will only send the called number to an application or extension. You should have an audio file created before calling the playback app. So you code will look like this:

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
})

To generate the audio file you can use the google api, see examples at https://cloud.google.com/text-to-speech/docs/reference/libraries

Jeferson Daniel
  • 173
  • 2
  • 11
  • so there is no TTS solution? When administrating the Asterisk engine I use the FreePbx Admin Panel. I was hoping for an Asterisk TTS module –  Feb 26 '19 at 15:39
  • There is the Festival application but it depends on external software too. https://www.voip-info.org/asterisk-cmd-festival/ – Jeferson Daniel Feb 26 '19 at 21:03
  • But in general its better to create the audio file before doing the call, so the called number don't have to wait the audio generation. – Jeferson Daniel Feb 26 '19 at 21:05
  • I updated my question. I think I have to use TTS instead of generating files –  Feb 27 '19 at 07:59