kaushik
To convert Speech to Text in java
0 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners

package abc;

import javax.speech.*; import javax.speech.recognition.*;

import java.io.FileReader; import java.util.Locale;

public class HelloWorld extends ResultAdapter { static Recognizer rec; //Receives RESULT_ACCEPTED event: print it, clean up, exit public void resultAccepted(ResultEvent e) { Result r = (Result)(e.getSource()); ResultToken tokens[] = r.getBestTokens(); for (int i = 0; i < tokens.length; i++) System.out.print(tokens[i].getSpokenText() + " "); System.out.println(); // Deallocate the recognizer and exit try { rec.deallocate(); } catch (EngineException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (EngineStateError e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.exit(0); } public static void main(String args[]) { Recognizer rec; try { // Create a recognizer that supports English. rec = Central.createRecognizer( new EngineModeDesc(Locale.ENGLISH)); // Start up the recognizer //rec.allocate(); // Load the grammar from a file, and enable it FileReader reader = new FileReader("C:\abc.txt"); RuleGrammar gram = rec.loadJSGF(reader); gram.setEnabled(true); // Add the listener to get results rec.addResultListener(new HelloWorld()); // Commit the grammar rec.commitChanges(); // Request focus and start listening rec.requestFocus(); rec.resume(); } catch (Exception e) { e.printStackTrace(); } } }

Advertisement
View Answers









Related Tutorials/Questions & Answers:
To convert Speech to Text in java
To convert Speech to Text in java  package abc; import javax.speech.*; import javax.speech.recognition.*; import java.io.FileReader; import java.util.Locale; public class HelloWorld extends ResultAdapter { static Recognizer
Java (Text To Speech)
Java (Text To Speech)  How can a selected part of a webpage be pronounced using java Swing
Advertisements
Text To speech exception - Java Beginners
Text To speech exception  Sir/Madam, I want to create a application for text to speech. I am using Sysnthesizer class of speech package but it return null.Can you help me to create that. i am facing error in synth.allocate
text to speech code in jsp - Java Magazine
text to speech code in jsp  Is their any code in jsp for text to speech i.e when i enter text in text area and press submit button , the text i entered should come in voice as output
text to speech
text to speech  hello all. how we can use text to speech in our application in iphone??   hello if you want to use text to speech synthesizer then you have to import voiceService.framework and the write some code
Speech Processing - Java Beginners
Speech Processing  I want to implement Speech Processing in Java. How can I do It? Please Answer me
Use of SVOX SDK 5.0.0 for text to speech in iphone project
Use of SVOX SDK 5.0.0 for text to speech in iphone project  how to implement svox sdk for text to speech in xcode. I need a sort of exmaple for it...awaitinh ofr your reply thanks
Use of SVOX SDK 5.0.0 for text to speech in iphone project
Use of SVOX SDK 5.0.0 for text to speech in iphone project  how to implement svox sdk for text to speech in xcode. I need a sort of exmaple for it...awaitinh ofr your reply thanks
how to convert text file to xml file in java. - XML
how to convert text file to xml file in java.  Hi all, I m having some problem. Problem is I want to convert a text file which is having the no of record(i.e no of different line of information)to a xml file through java
convert data from pdf to text file - Java Beginners
convert data from pdf to text file   how to read the data from pdf file and put it into text file(.txt
Convert text file to XML file in Java
Convert text file to XML file Java In this section, you will learn how to convert the text file into xml file in Java language. To do this, we have used StreamResult which acts as an holder for a transformation result in XML. After
Convert pdf to text file using Java
How to Convert pdf to text file in Java In this section, you will learn how to convert pdf file to text file in Java Programming. We have used itext api for this purpose. To read resume.pdf  file, we have used PDFReader class
how to convert a text file thats is in russian to english and vice versa using java ?
how to convert a text file thats is in russian to english and vice versa using java ?   Hello, I am a beginner to java, I want to convert a text file which is in english to russian and vice versa Kindly advice me Thanks
text to speect - Java Beginners
text to speect  please i need a j2me library that convert text to speech on me please any one can help me my email is ahmed_akl2010@yahoo.coim
Convert Text to Binary
Convert Text to Binary       In this section, we will learn how to convert Text to Binary. The following program provides you the functionality to convert Text to Binary
Convert Text to Binary
Convert Text to Binary       In this section, we will learn how to convert Text to Binary. The following program provides you the functionality to convert Text
Convert Text File to PDF file
Convert Text File to PDF file  Here is the way how to covert your Text file to PDF File, public class TextFileToPDF { private static void...(inLine); System.out.println("Text is inserted into pdf file
Convert Text File to PDF file
Convert Text File to PDF file  import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.FileReader; import...); System.out.println("Text is inserted into pdf file"); document.close
Convert Text to HTML
Convert Text to HTML       In this section, We are discussing the conversion of text into html file .This program functionally provides you converting text to html file by using
Convert Text To Word
Convert Text To Word       In this example, You will learn how to convert text to word file. Here, we are going to discuss about the conversion of text to word file.  Core
how to convert image file to text file?
how to convert image file to text file?  hi, can anybody tell how to convert image file to text file? plz help me
How to Convert Text Files into Gzip File
How to Convert Text Files into Gzip File  Hi, I am developing a small application using PHP language. The real problem is that how do i convert the text files into gzip file. how can i solve the problem.... Tnanks
voice to text in java
to text conversion and so if i can convert speech to text then i can easily go...voice to text in java  i'm doing my mini project and my objective is to create a pdf interface using netbeans and instead of text search option,i
How to convert into to String in Java?
How to convert into to String in Java?  Hi, How to convert into to String in Java? Thanks
What is TTS?
stands for  text-to-speech,. It  is the digitized audio rendering software that  converts  the computer text into speech. This ...; TTS  is that it is able to  convert text files into audio MP3 files
converting java class to java fx class
converting java class to java fx class   i am working on a java project which would convert text to speech and speech to text. i have developed a java file that would work for text to speech. it is working fine as a .java file
How to convert string to byte in Java
How to convert string to byte in Java  How to convert string to byte in Java
Java program - convert words into numbers?
Java program - convert words into numbers?   convert words into numbers?   had no answer sir
Convert Text To PDF
Convert Text To PDF       Here we are discussing the convertion of a text file into a pdf file...\completed>java TextToPDF Enter text: Hi, I am Rajesh Kumar Text is inserted
Convert Text To XML
Convert Text To XML       Here we are discussing the conversion of a text file into xml... are in text format which is taken as input from console. To convert
Speech Writing Services,Business Speech Writing,Speech Writing Outsoucing India,Affordable Speech Writing Services
Speech Writing Speech Writing Business owners are often called upon.... But if you are prepared with a well-structured speech, it can help