Kate Stohr
Kate Stohr

Reputation: 109

Why do i get a 'Broken pipe" error when trying to connect to IBM Watson API?

When trying to connect to IBM WATSON's Speech-to-Text API using the Python SDK and following the example in the documentation here, I get the following error:

"ConnectionError: ('Connection aborted.', error(32, 'Broken pipe')) while doing POST request to URL."

    speech_to_text = SpeechToTextV1(
    username=os.environ['WATSON_SPEECH_USERNAME'],
    password=os.environ['WATSON_SPEECH_PASSWORD'], 
    x_watson_learning_opt_out=False
)

def speech_to_text_api_call(audio_filename):
    with open(audio_filename, 'rb') as a_file:
       http_response = speech_to_text.recognize(
           a_file, 
           content_type='audio/wav',
           word_alternatives_threshold = 0.5,
           word_confidence = True,
           timestamps = True,
           profanity_filter = False,
           smart_formatting = True,
           speaker_labels = True,)
    return http_response

test = speech_to_text_api_call('temp/test-audio.wav')

I thought the SDK was meant to manage a streaming request. It is not clear why I would get an error of this nature. Welcome solutions...

Upvotes: 0

Views: 660

Answers (1)

Kate Stohr
Kate Stohr

Reputation: 109

Well, I lost at least an hour on this so sharing with others... the issue was a typo passing my credentials (username twice). However, instead of returning an error message that said something of the nature of 'unauthorized credentials' as you would expect it timed out the connection.

All to say... if you get this error trying to connect to the Watson API, it may well be a credentials issue. Check your username and password.

Upvotes: 2

Related Questions