IBM Watson SpechtoTextV1 error - Python

I am trying to figure out the IBM Watson api speech text. However, it works with short length audio files, but not audio files that are about 5 minutes long. This gives me the error below "watson {'code_description': 'Bad Request', 'code': 400, 'error': 'No messages found in 30 seconds.'}"

I am using a trial Watson account. Is there a limitation in the case of a trial account? or error below code.

Python code: -

from watson_developer_cloud import SpeechToTextV1

speech_to_text = SpeechToTextV1(
    username='XXX', 
    password='XXX',
    x_watson_learning_opt_out=False
)

with open('trial.flac', 'rb') as audio_file:
    print(speech_to_text.recognize(audio_file, content_type='audio/flac', model='en-US_NarrowbandModel', timestamps=False, word_confidence=False, continuous=True))

      

Appreciate any help!

+4


source to share


2 answers


Please see the implementation notes in the Speech to Text API for the recognized API you are trying to use:

Implementation notes

Sends audio and returns transcription results for a session recognition request. Returns only final results; c allow intermediate results, use session requests, or use the WebSocket API. The service sets a data size limit of 100 MB. This automatically detects the fidelity of the incoming sound, and for audio that includes multiple channels, downmixes the audio to single channel mono during transcoding.

Streaming mode

For requests to transcribe live audio as it becomes available or transcribes multiple audio files with multi-request requests, you must set the Transfer-Encoding header to chunked to use streaming. In streaming mode, the server closes the connection (status code 408) if the service does not receive a block of data within 30 seconds and the service has no sound to transcribe for 30 seconds. The server also closes the connection (status code 400) if no speech is defined for inactivity_seconds for audio seconds (not processing time); use the inactivity_timeout parameter to change the default to 30 seconds.

There are two factors here. Firstly, the data size limit is 100 MB, so I wouldn't send more files than to the Speech to Text service. Second, you can see that the server will close the connection and return a 400 error if no speech is detected within the seconds defined for inactivity_timeout. The default seems to be 30 seconds, so this matches the error you see above.



I would suggest that you make sure there is valid speech in the first 30 seconds of your file and / or make the inactivity_timeout larger to see if the problem exists. To keep things simple, you can test the error file and other sound files using the browser API in your browser:

Feedback in the text API

+1


source


The API documentation has this Python code, it will not shutdown the server after the default 30 second period, and works for other errors as well.

It's like trying and throwing, with the extra step of creating an instance of the function in the class.



def on_error(self, error):
        print('Error received: {}'.format(error))

      

Here is the link https://cloud.ibm.com/apidocs/speech-to-text?code=python

0


source







All Articles