Results 1 to 2 of 2

Thread: Speech To Text

  1. #1
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Unhappy Speech To Text

    I have a code and i had defined the grammar files..But still get the text when i speak the words defined in the grammer what might be the problem

    Java Code:
    //package com.sarf.talkingjava;
    
    import javax.speech.Central;
    import javax.speech.recognition.*;
    
    import java.io.FileReader;
    import java.util.Locale;
    
    public class SpeechToTextConverter extends ResultAdapter {
          static Recognizer recognizer;
    		//Receives RESULT_ACCEPTED event: print it
          public void resultAccepted(ResultEvent resultEvent) {
                Result result = (Result)(resultEvent.getSource());
                ResultToken resultToken[] = result.getBestTokens();
    		
                for (int nIndex = 0; nIndex < resultToken.length; nIndex++){
                      System.out.print(resultToken[nIndex].getSpokenText() + " ");
                }
                try {      
    
                      // Deallocate the recognizer
                      recognizer.forceFinalize(true);          
                      recognizer.deallocate();
                }catch (Exception exception) {
                      exception.printStackTrace();
                }
                System.exit(0);
          }
    
          public static void main(String args[]) {
                try {
                      Central.registerEngineCentral 
                           ("com.cloudgarden.speech.CGEngineCentral");
                      RecognizerModeDesc desc = 
                           new RecognizerModeDesc(Locale.US,Boolean.TRUE);
    					
                      // Create a recognizer that supports US English.
                      recognizer = Central.createRecognizer(desc);
    				  
    				  // Start up the recognizer
                      recognizer.allocate();
    				  
                      // Load the grammar from a file, and enable it
                     FileReader fileReader =  
                         new FileReader("C:\\Users\\Priyanka\\Desktop\\my_grammar.grammar");
    					 RuleGrammar grammar = recognizer.loadJSGF(fileReader);
    				 
                      grammar.setEnabled(true);
    				  
                      // Add the listener to get results
                     // recognizer.addResultListener(new SpeechToTextConverter());
    				 grammar.addResultListener(new SpeechToTextConverter());
    				  
                      // Commit the grammar
                      recognizer.commitChanges();
    				  recognizer.waitEngineState(Recognizer.LISTENING);
    				  
                      // Request focus and start listening
                      recognizer.requestFocus();
    				  recognizer.resume();
    				  
    				//System.out.println("working");
                      recognizer.waitEngineState(Recognizer.FOCUS_ON);
    					recognizer.forceFinalize(true);         
    					recognizer.waitEngineState(Recognizer.DEALLOCATED);
    				  
    
    
                } catch (Exception e) {
                      e.printStackTrace();
                      System.exit(0);
                }
          }
    }

    The output that i get is nothing its not recognizing the speech that i m giving please help me

  2. #2
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Speech To Text

    Priyanka can u pls help me with the above project....I am really struck with this and i need this very badly as i chose this as my Engineering project....Pls help me..Can u pls expalin me bat the part (Central.registerEngineCentral
    ("com.cloudgarden.speech.CGEngineCentral");)
    in ur project....

Similar Threads

  1. speech.properties
    By Parneel in forum Advanced Java
    Replies: 1
    Last Post: 12-30-2012, 03:24 PM
  2. Text To Speech
    By jyothi.priyanka in forum Advanced Java
    Replies: 0
    Last Post: 02-24-2011, 06:00 PM
  3. Speech in Web Application
    By vinoopraj in forum Advanced Java
    Replies: 0
    Last Post: 06-23-2010, 12:27 PM
  4. speech to text concersion
    By ak88 in forum Advanced Java
    Replies: 1
    Last Post: 03-09-2010, 09:57 AM
  5. Capture speech and convert it to text in a textbox
    By Cyber Dragon in forum Advanced Java
    Replies: 1
    Last Post: 04-25-2009, 05:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •