LumenVox Java Pizza Application
Java on Asterisk

Steve Prior comments about his experience with speech recognition: "While I was exploring the possibilities with LumenVox, it occured to me that writing and maintaining a complex speech application would be easiest with a high level language rather than a normal Asterisk Dial Plan. Working with LumenVox to ensure compatibility with the FastAGI protocol has now enabled applications to be written in any of the languages with FastAGI bindings."

"In my case I chose to use Stefan Reuter's asterisk-java project to write my LumenVox voice enabled application in Java. This has allowed me to write a speech application which uses J2EE technologies like CORBA and Hibernate database access to interface with my home automation system. The amazing part is that all of this works very well when calling through the hands-free functions of my car calling through my cell phone into a VOIP connection to my Asterisk server — even with the background noise level of highway speeds and snow tires!"

Serving Up Java on Asterisk

Author: Steve Prior

// The program starts off playing the Gino’s Pizza greeting and setting threshold for accepting Speech Recognition results.

PizzaOrder pizzaOrder = new PizzaOrder();
this.streamFile("GP-Greeting");
this.setVariable("THRESHOLD","500");
      
// Ask if delivery or take out

pizzaOrder.setDeliveryOrTakeout(ask("order", "GP-DeliveryorTakeout", "GP-NoDeliveryorTake-out", true, getThreshold()));

// Ask for Size 

pizzaOrder.setSize(ask("size", "GP-Size", "GP-NI", true, getThreshold()));

// Ask for Crust 

pizzaOrder.setCrust(ask("crust", "GP-Crust", "GP-NI", true, getThreshold()));
      
// Ask for Toppings

getPizzaTypeOrToppings(pizzaOrder);

// Confirm playing back the entire order  
 
speakOrder(pizzaOrder);

// Loop until everything looks good

String wasThisRight = ask("yes_no", "GP-WasThisRight", "GP-NI", true, getThreshold());

// If something was not right, then goto menu that fixes the order.
      
if (wasThisRight.equals("no"))
{
    pizzaOrder = getFixedOrder(pizzaOrder);
}

// Return the final order

return pizzaOrder;

// Common functionality in the each menu of the program is asking a question & getting an answer -- which is at or above a preset confidence threshold.
                    
Download Code

© 2016 LumenVox, LLC. All rights reserved.