我們遇到了一個奇怪的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