Results 1 to 13 of 13
  1. #1
    Saran185 is offline Member
    Join Date
    Jan 2011
    Posts
    36
    Rep Power
    0

    Question wav file to text

    hi...
    I want to learn how to convert a wav file to a text file in java. The audio must get converted to text. Pls help me in dis and what are the required dll files to be included.

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Use the javax.sound.sampled.AudioSystem.getAudioFileFormat () to get an AudioFormat. Then use 'getFormat()' on the returned object to get an AudioFormat. That will give you information about number of channels, sample rate, endianness, etc.

    Use that to create an AudioInputStream. You can then read bytes into a byte array. Wrap the byte array in a ByteBuffer and read the samples according to the information from the AudioFormat. Now you have sampled sound and you can write it to a text file in whatever format you choose.

  3. #3
    Saran185 is offline Member
    Join Date
    Jan 2011
    Posts
    36
    Rep Power
    0

    Default

    hi.. i have done with the first part what u have said. I have got the format of audio played. Now using this info how to get the words. I have a byte array from audio input stream. now this byte array displays only integers. I want to convert the it so that the words are displayed. Can you explain me with any proper examples so that it will be of great help to me.

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    What do you mean by "words"?

  5. #5
    Saran185 is offline Member
    Join Date
    Jan 2011
    Posts
    36
    Rep Power
    0

    Default

    the words mean the contents of the wav file. Assume that my wav file is a passage that is read by a person. now i want the passage- the contents of the wav file to be displayed. how to stream the data from the audio file. its like we have to use speech to text api. can u further guide me in proceeding this. pls....

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default

    You want to do a speech to text app?

    Then do you not think you should have asked that question instead?

  7. #7
    Saran185 is offline Member
    Join Date
    Jan 2011
    Posts
    36
    Rep Power
    0

    Default

    its not an application as such. but its using the speech to text api. im new to this and so kindly guide me.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default

    Why didn't you say that though?
    Have you been through the JSAPI and tutorials?
    What code do you have at the moment?
    What problems do you have?

  9. #9
    Saran185 is offline Member
    Join Date
    Jan 2011
    Posts
    36
    Rep Power
    0

    Default

    thanks for listening to me and helping me..

    as of now i have a code which converts speech to text. The code uses a grammar file. In the grammar file a set of sentences are given. only for those sentence the program recognises voice and displays them. But i want the program to recognise audio or the speech dynamically(generic manner) . Wat is to be done.
    Java Code:
    import javax.speech.Central;
    import javax.speech.recognition.*;
    
    import java.io.FileReader;
    import java.util.Locale;
    
    public class SpeechToTextConverter extends ResultAdapter {
          static Recognizer recognizer;
    
          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("D:\\my_grammar.grammar");
                      RuleGrammar grammar = recognizer.loadJSGF(fileReader);
                      grammar.setEnabled(true);
    
                      // Add the listener to get results
                      recognizer.addResultListener(new SpeechToTextConverter());
    
                      // Commit the grammar
                      recognizer.commitChanges();
                      recognizer.waitEngineState(Recognizer.LISTENING);
    
                      // Request focus and start listening
                      recognizer.requestFocus();
                      recognizer.resume();
    
                      recognizer.waitEngineState(Recognizer.FOCUS_ON);
    
                      recognizer.forceFinalize(true);               
                      recognizer.waitEngineState(Recognizer.DEALLOCATED);
    
    
                } catch (Exception e) {
                      e.printStackTrace();
                      System.exit(0);
                }
          }
    }
    the grammar file::::
    Java Code:
    #JSGF V1.0;
    
    grammar com.sarf.talkingjava.example;
    
    public <startExample> = (please | My name is sarf | 
    What is your Name | Good morning |Welcome to chennai| enjoy the|free roaming call|How are you |Open grammar |
    Please to meet you ) *;
    public <endExample> = [thanks | thank you | thank you very much];

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default

    This is rather a large area to be working on.
    It's not something a web forum is going to be able to help with to any great extent.

    Companies make nice profits from this sort of thing for a reason.

    Find a suitable technical book on speech recognition, for starters.

  11. #11
    Saran185 is offline Member
    Join Date
    Jan 2011
    Posts
    36
    Rep Power
    0

    Default

    ok thanks..i will try with any books on speech synthesis..

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default

    Not speech synthesis.
    Speech recognition.

    Speech synthesis would be going from text to speech, which is an easier thing.

  13. #13
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    The FAQ for JSAPI has the following:

    Does JSAPI allow me to control the audio input source of a recognizer or redirect the audio output of a speech synthesizer?

    This support is currently not in JSAPI. We plan to use the Java Sound API to help provide this support in the future. We purposely left room for expansion in the javax.speech.AudioManager interface and will further investigate this support after the Java Sound API is finalized.
    It does not appear that JSAPI has support at this time for file base speech recognition.

Similar Threads

  1. Replies: 1
    Last Post: 02-28-2011, 05:30 PM
  2. Replies: 0
    Last Post: 12-09-2010, 05:56 PM
  3. Replies: 2
    Last Post: 06-14-2010, 10:18 AM
  4. Replies: 8
    Last Post: 11-06-2009, 06:52 AM
  5. find and replace text from a text file
    By gezzel in forum New To Java
    Replies: 2
    Last Post: 09-19-2008, 04:04 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
  •