All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.asteriskjava.fastagi.command.SpeechRecognizeCommand Maven / Gradle / Ivy

There is a newer version: 3.39.0
Show newest version
/*
 *  Copyright 2004-2006 Stefan Reuter
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package org.asteriskjava.fastagi.command;

/**
 * Plays back given prompt while listening for speech and dtmf.

* Available since Asterisk 1.6. * * @author srt * @version $Id$ * @since 1.0.0 */ public class SpeechRecognizeCommand extends AbstractAgiCommand { /** * Serial version identifier. */ private static final long serialVersionUID = 1L; private String prompt; private int timeout; private int offset; /** * Creates a new SpeechRecognizeCommand that plays the given prompt and listens for for speech and dtmf. * * @param prompt the prompt to play. * @param timeout the maximum recognition time in milliseconds. */ public SpeechRecognizeCommand(String prompt, int timeout) { this.prompt = prompt; this.timeout = timeout; this.offset = 0; } /** * Creates a new SpeechRecognizeCommand that plays the given prompt and listens for for speech and dtmf. * * @param prompt the prompt to play. * @param timeout the maximum recognition time in milliseconds. * @param offset the offset samples to skip when playing the prompt. */ public SpeechRecognizeCommand(String prompt, int timeout, int offset) { this.prompt = prompt; this.timeout = timeout; this.offset = offset; } /** * Returns the prompt to play. * * @return the prompt to play. */ public String getPrompt() { return prompt; } /** * Sets the prompt to play. * * @param prompt the prompt to play. */ public void setPrompt(String prompt) { this.prompt = prompt; } /** * Returns the maximum recognition time in milliseconds. * * @return the maximum recognition time in milliseconds. */ public int getTimeout() { return timeout; } /** * Sets the maximum recognition time in milliseconds. * * @param timeout the maximum recognition time in milliseconds, or -1 for no timeout. */ public void setTimeout(int timeout) { this.timeout = timeout; } /** * Returns the offset samples to skip when playing the prompt. * * @return the offset samples to skip when playing the prompt. */ public int getOffset() { return offset; } /** * Sets the offset samples to skip when playing the prompt. * * @param offset the offset samples to skip when playing the prompt. */ public void setOffset(int offset) { this.offset = offset; } @Override public String buildCommand() { return "SPEECH RECOGNIZE " + escapeAndQuote(prompt) + " " + timeout + " " + offset; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy