package SpeechGet; import edu.cmu.sphinx.frontend.util.*; import edu.cmu.sphinx.recognizer.Recognizer; import edu.cmu.sphinx.result.Result; import edu.cmu.sphinx.util.props.ConfigurationManager; public class SpeechGet { public static void main(String args[]){ ConfigurationManager cm; cm=new ConfigurationManager(); Recognizer recognizer=(Recognizer) cm.lookup("recognizer"); try{ recognizer.allocate(); } catch(Exception e){ System.out.println("EXCEPTION!! RECOGNIZER"); } Microphone microphone=(Microphone) cm.lookup("microphone"); try{ if(!microphone.startRecording()){ System.out.println("Cant record"); recognizer.deallocate(); System.exit(0); } } catch(Exception e){System.out.println("EXCEPTION!! MIC");} while(true){ System.out.println("start speaking"); try{ Result result=recognizer.recognize(); if(result!=null){ try{ String result_text=result.getBestPronunciationResult(); System.out.println("you said :"+result_text+"\n"); } catch(Exception e){ System.out.println("Exception result etbestprononciatio"); } } else System.out.println("you said nothinh \n"); } /*always prints this error below*/ catch(Exception e){System.out.println("EXCEPTION!! Result"+e.getMessage());} } } }