watson-developer-cloud / speech-android-sdk

DEPRECATED - Please use https://github.com/watson-developer-cloud/android-sdk
Apache License 2.0
67 stars 53 forks source link

Response different than java-sdk #29

Closed simranjeetsood closed 8 years ago

simranjeetsood commented 8 years ago

I have been using the speech-android-sdk in my app and have correctly integrated it in my app. Its working perfectly and is correctly giving me the recording results. My question is: the response received in java-sdk as mentioned on watson STT API reference on IBM is of the format

{
  "results": [
    {
      "word_alternatives": [
        {
          "start_time": 0.03,
          "alternatives": [
            {
              "confidence": 0.9496,
              "word": "the"
            }
          ],
          "end_time": 0.09
        },
        . . .
        {
          "start_time": 0.86,
          "alternatives": [
            {
              "confidence": 0.9471,
              "word": "report"
            }
          ],
          "end_time": 1.51
        }
      ],
      "alternatives": [
        {
          "timestamps": [
            [
              "the",
              0.03,
              0.09
            ],
            . . .
            [
              "report",
              0.86,
              1.51
            ]
          ],
          "confidence": 0.985,
          "transcript": "the latest weather report "
        }
      ],
      "final": true
    }
  ],
  "result_index": 0
}

In the android SDK, the response is received by onResponse(String s) method implemented by SpeechDelegate. The response received by this method as String s is of the format:

{  "results": [ {
                      "alternatives": [
                                              {
                                               "confidence": 0.766, 
                                               "transcript": "okay asking again "
                                               }
                                                ], 
                                                "final": true
                       }
                     ], 
"result_index": 0
 }

If I want to access the "timestamps" and "word_alternatives" entries in the response, how should I go about it? P.S. I have implemented the SDK the same way its mentioned in the example project and its working perfectly.

mihui commented 8 years ago

@simranjeetsood simply set the timestamps as true, by default it is false; and set max_alternatives a desired value, by default it is 1. Right now timestamps is not available, but I have already submitted the pull request.

germanattanasio commented 8 years ago

I'm closing this because since @mihui already answered the question