To get started with the java api, it is recommended that you download the cli and take a look at the cli source code as examples. You can also use the cli project as a starting point. It has all the required jars and a basic ant script.
To decode an audio file simply use this code:
If you have a stream, rather than a file you can use the recognize method that takes an AudioInputStream rather than a File. Note you may need to take care to do endpointing depending on the nature of your stream. The endpointing flag will do endpointing on the server. But your stream must be closed for a response to be returned. This is one reason the client side endpointing is a good choice.
To decode audio from your microphone and use the client side endpointer, You can use the same httprecognizer object, but use the method that takes an endpointing stream. In this case create a micS4endpointingstream. Once setup and initialized it will start the http requests when speech is detected and start streaming the audio as an http attachment. It will close the stream when it detects the end of speech.
You can do end pointing on the client for streams and files in a similar manner use StreamS4EndPointingInputStream FileS4EndPointingInputStream in place of the MicS4EndPointingInputStream in the example above.
This example uses the cloud synthesizer to create audio for a text string.
The speechcloud java client comes with 3 endpointers
Both externalTriggeredEndpointer nad AudioStreamEndpointer send audio in wav format set mime type to "audio/x-wav" whne using them.
You can write your own custom endpointer that will work with endpointing streams.
In the do endpointing method you read from inputStream, check for startSpeech condition, when startSpeech occurs you must copy data to the outputStream. You must close the outpustream when the endspeech condition occurs.
You can configre the S4 endpointer do feature extraction on the client by setting the mimetype to "audio/x-s4feature".
To be specified.
| Copyright speechapi.com. 2009-2010 Contact Us |