IBM Speech to text api,无法进行HTTP POST

2024-10-04 11:28:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在制作一个python程序,它应该发送一个小的.wav音频剪辑并得到响应,我已经尝试了几件事,但我无法提出一个成功的请求,直到现在

更多详情: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/apis/#!/speech-to-text/recognizeSessionless

那些已经尝试过这个平台的人


Tags: https程序com剪辑www音频ibmspeech
1条回答
网友
1楼 · 发布于 2024-10-04 11:28:58

请尝试以下代码:

import requests

url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/recognize'
username = '<username>'
password = '<password>'

headers={'Content-Type': 'audio/wav'}

audio = open('./sheet.wav', 'rb')

r = requests.post(url, data=audio, headers=headers, auth=(username, password))

print(r.text)

相关问题 更多 >