public class SpeechToText extends WatsonService
defaultHeaders, MESSAGE_CODE, MESSAGE_ERROR, skipAuthentication, VERSION| Constructor and Description | 
|---|
| SpeechToText()Instantiates a new Speech to Text service. | 
| SpeechToText(String username,
            String password)Instantiates a new Speech to Text service by username and password. | 
| Modifier and Type | Method and Description | 
|---|---|
| ServiceCall<Void> | addTextToCustomizationCorpus(String customizationId,
                            String corpusName,
                            Boolean allowOverride,
                            File trainingData)Adds a single corpus text file of new training data to the custom language model. | 
| ServiceCall<Void> | addWord(String customizationId,
       Word word)Add/Updates a custom word to a custom language model. | 
| ServiceCall<Void> | addWords(String customizationId,
        Word... words)Adds one or more custom words to a custom language model. | 
| ServiceCall<Customization> | createCustomization(String name,
                   SpeechModel baseModel,
                   String description)Creates the customization. | 
| ServiceCall<RecognitionJob> | createRecognitionJob(File audio,
                    RecognizeOptions recognizeOptions,
                    RecognitionJobOptions recognitionJobOptions)Creates an asynchronous recognition request. | 
| ServiceCall<SpeechSession> | createSession()Creates a session to lock an engine to the session. | 
| ServiceCall<SpeechSession> | createSession(SpeechModel model)Creates a session to lock an engine to the session. | 
| ServiceCall<SpeechSession> | createSession(String model)Creates a session to lock an engine to the session. | 
| ServiceCall<Void> | deleteCorpus(String customizationId,
            String corpusName)Delete customization corpus. | 
| ServiceCall<Void> | deleteCustomization(String customizationId)Delete customization. | 
| ServiceCall<Void> | deleteRecognitionJob(String id)Delete recognition. | 
| ServiceCall<Void> | deleteSession(SpeechSession session)Deletes a  SpeechSession. | 
| ServiceCall<Void> | deleteWord(String customizationId,
          String wordName)Deletes a custom word from a custom language model. | 
| ServiceCall<List<Corpus>> | getCorpora(String customizationId)Gets the customization corpus list. | 
| ServiceCall<Customization> | getCustomization(String customizationId)Gets the customization information. | 
| ServiceCall<List<Customization>> | getCustomizations(String language)Gets all the customizations belonging to the user. | 
| ServiceCall<SpeechModel> | getModel(String modelName)Gets the speech model based on a given name. | 
| ServiceCall<List<SpeechModel>> | getModels()Gets the models. | 
| ServiceCall<RecognitionJob> | getRecognitionJob(String id)Gets the recognition. | 
| ServiceCall<List<RecognitionJob>> | getRecognitionJobs()Returns the status and id of all outstanding jobs. | 
| ServiceCall<SpeechSessionStatus> | getRecognizeStatus(SpeechSession session)Gets the session status. | 
| ServiceCall<WordData> | getWord(String customizationId,
       String wordName)Gets information about a word from a custom language model. | 
| ServiceCall<List<WordData>> | getWords(String customizationId,
        Word.Type type)Gets information about all the words from a custom language model. | 
| ServiceCall<SpeechResults> | recognize(File audio)Recognizes an audio file and returns  SpeechResults. | 
| ServiceCall<SpeechResults> | recognize(File audio,
         RecognizeOptions options)Recognizes an audio file and returns  SpeechResults.Here is an example of how to recognize an audio file: | 
| void | recognizeUsingWebSocket(InputStream audio,
                       RecognizeOptions options,
                       RecognizeCallback callback)Recognizes an audio  InputStreamusing aWebSocket.The RecognizeCallbackinstance will be called every time the service sendsSpeechResults.Here is an example of how to recognize an audio file using WebSockets and get interim results: | 
| ServiceCall<RecognitionCallback> | registerCallback(String callbackUrl,
                String secret)Registers a callback URL with the service for use with subsequent asynchronous recognition requests. | 
| ServiceCall<Void> | resetCustomization(String customizationId)Resets a custom language model by removing all corpora and words from the model. | 
| ServiceCall<Void> | trainCustomization(String customizationId,
                  Customization.WordTypeToAdd wordTypeToAdd)Initiates the training of a custom language model with new corpora, words, or both. | 
configureHttpClient, createServiceCall, getApiKey, getEndPoint, getName, getToken, processServiceCall, setApiKey, setAuthentication, setDefaultHeaders, setEndPoint, setSkipAuthentication, setUsernameAndPassword, toStringpublic ServiceCall<Void> addTextToCustomizationCorpus(String customizationId, String corpusName, Boolean allowOverride, File trainingData)
customizationId - The GUID of the custom language model to which a corpus is to be added. You must make the
        request with the service credentials of the model's owner.corpusName - The name of the corpus that is to be added. The name cannot contain spaces and cannot be the
        string user, which is reserved by the service to denote custom words added or modified by the user.allowOverride - Indicates whether the specified corpus is to overwrite an existing corpus with the same name.
        If a corpus with the same name already exists, the request fails unless allow_overwrite is set to true; by
        default, the parameter is false. The parameter has no effect if a corpus with the same name does not already
        exist. query.trainingData - A plain text file that contains the training data for the corpus. Encode the file in UTF-8 if
        it contains non-ASCII characters; the service assumes UTF-8 encoding if it encounters non-ASCII characters.public ServiceCall<Void> addWord(String customizationId, Word word)
SpeechToText#trainCustomization(String, Boolean).customizationId - The GUID of the custom language model to which a word is to be added. You must make the
        request with the service credentials of the model's owner.word - the word to add/updatepublic ServiceCall<Void> addWords(String customizationId, Word... words)
SpeechToText#trainCustomization(String, Boolean).customizationId - The GUID of the custom language model to which words are to be added. You must make the
        request with the service credentials of the model's owner.words - the list of words to be added.public ServiceCall<Customization> createCustomization(String name, SpeechModel baseModel, String description)
name - The customization namebaseModel - The name of the language model that is to be customized by the new model. e.g:
        'en-US_BroadbandModel'.description - the customization descriptionpublic ServiceCall<RecognitionJob> createRecognitionJob(File audio, RecognizeOptions recognizeOptions, RecognitionJobOptions recognitionJobOptions)
audio - the audiorecognizeOptions - the recognize optionsrecognitionJobOptions - the recognition job optionspublic ServiceCall<SpeechSession> createSession()
SpeechSessionpublic ServiceCall<SpeechSession> createSession(SpeechModel model)
model - the modelSpeechSessionpublic ServiceCall<SpeechSession> createSession(String model)
model - the modelSpeechSessionpublic ServiceCall<Void> deleteCorpus(String customizationId, String corpusName)
customizationId - The GUID of the custom language model from which the corpus is to be deleted. You must make
        the request with the service credentials of the model's owner.corpusName - the corpus namepublic ServiceCall<Void> deleteCustomization(String customizationId)
customizationId - The GUID of the custom language model being deleted. You must make the request with the
        service credentials of the model's owner.public ServiceCall<Void> deleteRecognitionJob(String id)
id - the idpublic ServiceCall<Void> deleteSession(SpeechSession session)
SpeechSession.session - the speech session to deletepublic ServiceCall<Void> deleteWord(String customizationId, String wordName)
customizationId - The GUID of the custom language model from which the word is being deleted. You must make
        the request with the service credentials of the model's owner.wordName - the word namepublic ServiceCall<List<Corpus>> getCorpora(String customizationId)
customizationId - The GUID of the custom language model whose corpora is being queried. You must make the
        request with the service credentials of the model's owner.public ServiceCall<Customization> getCustomization(String customizationId)
customizationId - The GUID of the custom language model being queried. You must make the request with the
        service credentials of the model's owner.public ServiceCall<List<Customization>> getCustomizations(String language)
language - The language for which custom models are to be returned.public ServiceCall<SpeechModel> getModel(String modelName)
modelName - the model nameSpeechModelpublic ServiceCall<List<SpeechModel>> getModels()
SpeechModelspublic ServiceCall<RecognitionJob> getRecognitionJob(String id)
id - the idpublic ServiceCall<List<RecognitionJob>> getRecognitionJobs()
public ServiceCall<SpeechSessionStatus> getRecognizeStatus(SpeechSession session)
recognize(File, RecognizeOptions) .session - the speech sessionpublic ServiceCall<WordData> getWord(String customizationId, String wordName)
customizationId - The GUID of the custom language model containing the word being queried. You must make the
        request with the service credentials of the model's owner.wordName - the word namepublic ServiceCall<List<WordData>> getWords(String customizationId, Word.Type type)
customizationId - The GUID of the custom language model to which a corpus is to be added. You must make the
        request with the service credentials of the model's owner.type - the word type. Possible values are: ALL, USER or CORPORA.public ServiceCall<SpeechResults> recognize(File audio)
SpeechResults. It will try to recognize the audio format based on the
 file extension.
 SpeechToText service = new SpeechToText();
 service.setUsernameAndPassword("USERNAME", "PASSWORD");
 service.setEndPoint("SERVICE_URL");
 SpeechResults results = service.recognize(new File("sample1.wav")).execute();
 System.out.println(results);
 audio - the audio fileSpeechResultsIllegalArgumentException - if the file extension doesn't match a valid audio typepublic ServiceCall<SpeechResults> recognize(File audio, RecognizeOptions options)
SpeechResults.
 SpeechToText service = new SpeechToText();
 service.setUsernameAndPassword("USERNAME", "PASSWORD");
 service.setEndPoint("SERVICE_URL");
 RecognizeOptions options = new RecognizeOptions().maxAlternatives(3).continuous(true);
 File audio = new File("sample1.wav");
 SpeechResults results = service.recognize(audio, options).execute();
 System.out.println(results);
 audio - the audio fileoptions - the recognize optionsSpeechResultspublic void recognizeUsingWebSocket(InputStream audio, RecognizeOptions options, RecognizeCallback callback)
InputStream using a WebSocket.RecognizeCallback instance will be called every time the service sends SpeechResults.
 SpeechToText service = new SpeechToText();
 service.setUsernameAndPassword("USERNAME", "PASSWORD");
 service.setEndPoint("SERVICE_URL");
 RecognizeOptions options = new RecognizeOptions().maxAlternatives(2).continuous(true);
 FileInputStream audio = new FileInputStream("sample1.wav");
 service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {
   @Override
   public void onTranscript(SpeechResults speechResults) {
     System.out.println(speechResults);
   }
 });
 audio - the audio input streamoptions - the recognize optionscallback - the callbackpublic ServiceCall<RecognitionCallback> registerCallback(String callbackUrl, String secret)
GET request from the service, after which the service responds with response code 201 to the
 original registration request. secret with the request, the service uses it as a key to calculate an
 HMAC-SHA1 signature of a random challenge string in its response to the request. The signature
 provides authentication and data integrity for HTTP communications.callbackUrl - the callback urlsecret - the secretpublic ServiceCall<Void> resetCustomization(String customizationId)
customizationId - The GUID of the custom language model being reset. You must make the request with the
        service credentials of the model's owner.public ServiceCall<Void> trainCustomization(String customizationId, Customization.WordTypeToAdd wordTypeToAdd)
getCustomization(String) method to poll the model's status.customizationId - The GUID of the custom language model being trained. You must make the request with the
        service credentials of the model's owner.wordTypeToAdd - the word type to addCopyright © 2015–2016 IBM Watson. All rights reserved.