Search code examples
ibm-cloudibm-watson

Watson speech to text with "interim_results = True" in python gives ValueError


When using the Watson Speech-to-Text service with Python SDK, setting interim_results = True gives me the following error every time:

File "c:\...\Miniconda2\Lib\json\decoder.py", line 367, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 16 column 2 - line 401 column 2 (char 256 - 8843)

I am running it with a .wav file that is about 6 seconds long (directory omitted):

with open("C:/Users/.../assistant_output.wav",
          'rb') as audio_file:
    transcript = speech_to_text.recognize(
        audio_file, content_type='audio/wav', interim_results = True)

When setting interim_results = False it works fine, but I would like to process with interim results.

Any idea why this is occurring?


Solution

  • As per the API documentation interim_results is only applicable when using sessions or websockets.

    Recognize audio Sends audio and returns transcription results for a sessionless recognition request. Returns only the final transcription results; to enable interim results, use Sessions or WebSockets.

    https://www.ibm.com/watson/developercloud/speech-to-text/api/v1/#recognize_audio_websockets