Upgrade 3CX to v18 and get it hosted free!

Asterisk cmd Festival

Author image

Festival()

Synopsis

Say text to the caller

Description:

Festival(text,intkeys)

Uses the Festival open-source speech synthesizer (which you need to have installed) to generate the specified text as a sound stream. The intkeys parameter is optional. If present, it specifies the buttons that, if dialed by the caller, will cause the playing of the sound stream to stop, and for Festival returns the button pressed. If you specify the intkeys parameter as “any”, then Festival will return at the first button dialed, regardless of what it is. Please note that the intkeys parameter has to be enclosed by single quotes (‘) and there must not be a space between text, the comma and intkeys (see example).

The text parameter should be enclosed in quotation marks if there are any spaces.

Festival is not an application that will automatically answer the channel – so you need to do it yourself.

Example

exten => 003,1,Answer
exten => 003,2,Festival(‘Hello asterisk user, how are you today?’) ; <– note the quotes …
exten => 003,3,Festival(‘And an example the user can stop by pressing any key’,’any’) ; note quotes and no spaces
Remember to Answer the channel before using the Festival command.

Tip

You may get better results using the System command to access Festival’s text2wave program to generate a .WAV file, and then use the Asterisk cmd BackGround or Playback commands, rather than using Asterisk’s Festival command.

% text2wave -o myfile.ulaw -otype ulaw

Will take text from stdin and make a sound file of the text in ulaw format. You can simply use Playback(myfile) to play it through asterisk.
If you have problems with Festival seeming to drop some of the text, this may be for you. Also, if you have a lot of intensive processing (this in itself is intensive processing) you may want to spin this off into the background, and then play music or instructions for your user in the meantime. For example:


exten => s, 1, System(do_stuff &)
exten => s, 2, Playback(introduction-instructions)
exten => s, 3, Playback(my_new_sound)

  *****   do_stuff *****
  #!/usr/bin/php
  <?php
  // Take care of all your processing.
  $data = "A lot of text or something here.";
  system("echo $data | text2wave -o my_new_sound.ulaw -otype ulaw -");
  ?>

Something like that will allow you to do a bunch of heavy processing without forcing the user to wait on you.

See also


Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.