我们遇到了一个奇怪的watson API行为。Watson API返回408状态码
我们正在使用Watson的语音转文本来转录音频文件,并且最近已升级到较新版本的python sdk。现在,对于一个特定的文件(49 min
,45 MB wave file
),Watson API始终以status code 408
和消息Session timed out
响应。
它主要发生在我们的登台服务器上,并且在我们的本地环境中大部分时间都正常工作(我们只能在多次尝试中重现它)。我们的逻辑假定在每次请求之前创建新会话。
我们检查了API文档,但找不到任何解决方案。我们使用python 3.5
以及watson-developer-cloud==0.26.0
。
你有什么想法如何解决这个问题?
编辑:代码这是负责的要求
speech_to_text = SpeechToTextV1(
username=WATSON_USER,
password=WATSON_PASSWORD
)
with open(path, 'rb') as audio_file:
return speech_to_text.recognize(
audio_file,
content_type=kwargs.get('content_type'),
timestamps=kwargs.get('timestamps'),
inactivity_timeout=kwargs.get('inactivity_timeout'),
word_alternatives_threshold=kwargs.get('word_alternatives_threshold'),
word_confidence=kwargs.get('word_confidence'),
model=kwargs.get('model'),
profanity_filter=kwargs.get('profanity_filter'),
smart_formatting=kwargs.get('smart_formatting'),
speaker_labels=kwargs.get('speaker_labels'),
)
参数我们发送
content_type = "wav"
timestamps = True
inactivity_timeout = -1
word_alternatives = 0.99
word_confidence = True
profanity_filter = False
smart_formatting = True
speaker_labels = True
model = en-US_NarrowbandModel
请张贴一些代码:[如何创建一个最小,完整和可验证的示例](https:// stackoverflow。com/help/mcve) – TheDarkKnight
@TheDarkKnight谢谢你的评论,我已经用我们使用的代码更新了帖子 – mateuszb