simple and natural:
use your voice
With MultiModalBerry you can, with just a few line of code, develop an application controlling your Text-to-Speech (TTS) and Automatic Speech Recognition (ASR) engines.
the following example shows how you can with few lines:
import java.io.Console;
import java.io.IOException;
import com.dotvocal.jberry.AsrRecException;
import com.dotvocal.jberry.GrammarException;
import com.dotvocal.jberry.IRecognizer;
import com.dotvocal.jberry.JBerry;
import com.dotvocal.jberry.NoInputException;
import com.dotvocal.jberry.NoMatchException;
import com.dotvocal.jberry.TimeOutException;
public class Main
{
public static void main(String[] args)
{
try
{
IRecognizer recognizer = JBerry.createRecognizer();
recognizer.addGrammar("res\\nomi.bnf");
System.out.println("Please, tell me a name:");
String detto = recognizer.listen().getBestValue();
System.out.println("You said: " + detto);
}
catch (NoMatchException nme) { System.out.println("I didn't understand"); }
catch (TimeOutException toe) { System.out.println("Time out"); }
catch (NoInputException nie) { System.out.println("I didn't hear you"); }
catch (BerryConfigurationError bce){ System.out.println(bce.getMessage()); }
catch (GrammarException ge) { System.out.println(ge.getMessage()); }
catch (AsrRecException are) { System.out.println(are.getMessage()); }
catch (Exception ex) { System.out.println(ex.toString()); }
}
}
The example below shows how to use MultiModal Berry in order to:
import com.dotvocal.jberry.BerryConfigurationError;
import com.dotvocal.jberry.ISpeaker;
import com.dotvocal.jberry.JBerry;
import com.dotvocal.jberry.TtsException;
public class Main
{
public static void main(String[] args)
{
try
{
ISpeaker speaker = JBerry.createSpeaker();
speaker.speak("Hello World");
speaker.barrier();
}
catch (TtsException tte){System.out.println(tte.toString());}
catch (BerryConfigurationError bce){System.out.println(bce.toString());}
catch (Exception ex){System.out.println(ex.toString());}
}
}