2017-05-23 35 views
0

当试图使用Python SDK连接到IBM WATSON的Speech-to-Text API并遵循文档here中的示例时,我得到以下错误:当试图连接IBM Watson API时,为什么会出现'Broken pipe'错误?

“ConnectionError:( '连接异常中止',错误(32, '破碎管'​​)),而这样做POST请求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') 

我认为SDK是为了管理一个流媒体请求,目前还不清楚为什么我会得到这种性质的错误。欢迎使用解决方案...

回答

1

好吧,我至少在这个小时上失去了一个小时,这样与他人分享......问题是一个错字通过我的凭据(用户名两次)。但是,不会返回一条错误消息,说明“未授权凭据”的性质,因为您期望它会超时连接。

全部要说...如果您尝试连接到Watson API时出现此错误,那么很可能是凭证问题。检查您的用户名和密码。

相关问题