watson-developer-cloud / android-sdk

:high_brightness: Android SDK to use the IBM Watson services.
http://watson-developer-cloud.github.io/android-sdk/
Apache License 2.0
146 stars 94 forks source link

audiofilewritter method in android sdk (SUPPORT) #71

Closed prokulit06 closed 5 years ago

prokulit06 commented 5 years ago

can you provide example of audiofilewritter becase in your example audiofilewritter is not include can you add that ?? audiofilewritter is the method to transcribe audio to text ?? is that right??

prokulit06 commented 5 years ago

please i need your help i posting so many question about it in stackoverflow but no one can answer me :( please need help

lpatino10 commented 5 years ago

@prokulit06 if you're trying to transcribe audio to text, take a look at the example file.

You don't need to interface directly with the AudioFileWriter class, you just need to use the MicrophoneHelper.

If you look at the example, you'll see that it's first instantiated with the current activity:

// this refers to the MainActivity
private MicrophoneHelper microphoneHelper = new MicrophoneHelper(this);

Later on, we use the getInputStream() method of MicrophoneHelper to create a MicrophoneInputStream. This is what grabs our audio and allows us to pass it to the Watson APIs.

private MicrophoneInputStream capture = microphoneHelper.getInputStream(true);

A little bit more information about MicrophoneHelper can be found in the README here. This helps explain what true means in the getInputStream() method.

Now, we just need to pass that to the Watson Speech to Text API. We need to create a new thread, since network calls can't be made on the main one.

new Thread(new Runnable() {
  @Override
  public void run() {
    try {
      speechService.recognizeUsingWebSocket(getRecognizeOptions(capture),
        new MicrophoneRecognizeDelegate());
    } catch (Exception e) {
      showError(e);
    }
  }
}).start();

MicrophoneRecognizeDelegate is a class you create to handle the various recognition states. You can find its definition in the example code I linked.

prokulit06 commented 5 years ago

thank you my problem was solved