1
votes

I am making a python program which is supposed to send a small .wav audio clip and get the response , i have tried several things but i am unable to make a successful request till now

more details : https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/apis/#!/speech-to-text/recognizeSessionless

those who have already tried this platform

1

1 Answers

4
votes

Please try code below:

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)