public class SampleSpeechSearchCall extends CallListenerAbstract
The code below illustrates how to intercept a call and start a speech search.
First, to be able to intercept a call, you must implement a class that is
annotated with TheCallListener and either implement
CallListener
or extend
CallListenerAbstract
. This class is a
"listener" that allows you to intercept a call.
Next, you must implement a "speech search listener" class that implements SpeechSearchListener. This class allows you to be notified when important events related to a speech search have occurred. Specifically, if a match occurs for a speech search, then the method matchFound will be called with the match details. If an error occurred starting a speech search then startSearchFailed will be called, otherwise if the search is terminated for any reason then terminated method will be called.
In the callIntercepted method shown below the following occurs:
The search query used in the sample is an example of a insurance sales call. The call is searched for the presence of three concepts:
@TheCallListener public class SampleSpeechSearchCall extends CallListenerAbstract { private final Logger logger = Logger.getLogger(SampleSpeechSearchCall.class); @Override public void callIntercepted(Call call) { SearchQuery searchQuery = createSearchQuery(); SearchOptions options = SpeechFactory.createSearchOptions() .setLanguage("en_US") .setSearchQuery(searchQuery); UUID searchID = SpeechFactory.createSpeechService().startSearch(call, options, new MySpeechSearchListener()); logger.info("Search started with UUID " + searchID.toString()); } public SearchQuery createSearchQuery() { Concept greeting = SpeechFactory.createConcept() .setName("Greeting") .setOperator(SpeechFactory.createAnyOperator()) .setThreshold(45.0f) .addPhrase("Good Morning", 45.0f) .addPhrase("Hello", 45.0f); Concept introduction = SpeechFactory.createConcept() .setName("Introduction of Agent and Department") .setOperator(SpeechFactory.createAnyOperator()) .setThreshold(45.0f) .addPhrase("Welcome to", 45.0f) .addPhrase("My name is", 45.0f); Concept opening = SpeechFactory.createConcept() .setName("Opening") .setOperator(SpeechFactory.createAllOperator()) .setThreshold(45.0f) .setSubConcepts(greeting, introduction); Concept selling = SpeechFactory.createConcept() .setName("Selling") .setOperator(SpeechFactory.createAllOperator()) .setThreshold(45.0f) .addPhrase("Would you like to buy", 45.0f) .addPhrase("Could I offer you", 45.0f); Concept closing = SpeechFactory.createConcept() .setName("Closing") .setOperator(SpeechFactory.createAllOperator()) .setThreshold(45.0f) .addPhrase("Thank you for calling", 45.0f) .addPhrase("We appreciate your call", 45.0f); return SpeechFactory.createSearchQuery() .setLangauge("en_US") .setConcepts(opening, selling, closing); } private class MySpeechSearchListener implements SpeechSearchListener { @Override public void matchFound(UUID searchId, Call call, ListsearchMatches) { for (SpeechSearchMatch match : searchMatches) { logger.info("A match has been found for " + match.getName() + " at " + match.getStartTime() + " seconds"); } } @Override public void startSearchFailed(UUID searchId, Exception execption) { logger.info("The search failed due to errors[" + execption.getMessage() + "]"); } @Override public void terminated(UUID searchId, String reason) { logger.info("The search was terminated due to " + reason); } }; }
Constructor and Description |
---|
SampleSpeechSearchCall() |
Modifier and Type | Method and Description |
---|---|
void |
callIntercepted(Call call)
Intercept a call and start a speech search.
|
addParticipantFailed, callAlerting, callAnswered, callOriginated, callTerminated, mediaDetected, participantDropped
public void callIntercepted(Call call)
call
- the intercepted callCopyright © 2016 Avaya. All Rights Reserved.