10
I am trying to use IBM Cloud’s "Speech To Text" service in my Python application via POST requests with the package requests
.
The problem is that I am confused about the URL that should be used and also the form of the request. I saw some tutorials on the internet in which the boy uses the following URL:
https://gateway-lon.watsonplatform.net/speech-to-text/api/v1/recognize
But when going on the part of Management service, the URL I get is this:
https://api.us-east.speech-to-text.watson.cloud.ibm.com/instances/<um código aqui>
My Python code is this:
import requests
api_url = "<Uma das URL's que coloquei acima na pergunta>"
key = "<Chave da API (a chave está correta)>"
with open("audio.wav", "rb") as file:
audio = file.read()
response = requests.post(
api_url,
data = audio,
headers = {"Content-Type": "audio/wav"},
auth = ("apikey", key)
)
print(response.content)
When I try to use the first URL I get this answer:
b'{"code":403, "error": "Forbidden"}'
And by using the second URL I get this:
b'{"code":404, "error": "Not Found"}'.
What I’m doing wrong in the requisition?
Before you ask me if I’ve tried using the package
ibm_watson
, yes I have tried, but I found it very complicated. Therefore, I preferred to use the packagerequests
that I think is simpler.– JeanExtreme002