2

I am very new to this kind of stuff. This is my setup. enter image description here

Any suggestion is appreciated.

Jasfe
  • 23
  • 5
  • In general, it would be helpful if instead of screenshot, you could post the actual error message. In this case, you're getting "HTTP 401: Not authorized". Any guesses what that might mean ;) SUGGESTION: 1) Make sure you have an IBM ID (to access IBM resources), an API key (to access the test service) and you're using that API key with Postman (or curl, or however you're testing). Please try this tutorial: https://console.bluemix.net/docs/services/text-to-speech/getting-started.html#gettingStarted – paulsm4 Feb 21 '19 at 06:03

2 Answers2

6

Hi The issue is in Authorization, API key needs to be provided under Authorization tab, I would suggest to cross check API key via IBM console

Here is steps to convert text to speech using IBM watson with postman

  1. I assume you have ApiKey value, If you do not have Go to, IBM watson, create text-to-speech resource, -> Go to Manage -> You will have the API Key IBM console
  2. Go to Postman, create new Post request
  3. Now you need to add URL, Authorization using Basic Method, Headers & data refer Authorization Header data/body

Click on Send and you will receive audio under response -> Body tab

If you want to do quick check then you can use curl for the same

 curl -X POST \
    https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize \
      -H 'Accept: audio/wav' \
      -H 'Authorization: Basic REPLACE_API_KEY' \
      -H 'Content-Type: application/json' \
      -H 'Postman-Token: 3c147726-2f1e-4531-abca-0898127e8644' \
      -H 'cache-control: no-cache' \
      -d '{"text": "hello world"}'
Chandani Patel
  • 451
  • 4
  • 12
  • 1
    Oh, you are a lifesaver. I can never thank you enough. Since I have no coding background, this is exactly what I am looking for. – Jasfe Feb 21 '19 at 07:00
  • Great, happy that you got what you were looking for. +1 – Chandani Patel Feb 21 '19 at 07:02
  • For a `text to speech` request in postman, with the above settings I am getting this in response body tab: `{ "code_description": "Bad Request", "code": 400, "error": "No JSON object could be decoded" }` Edit: Ah, it is working now, i had to set it to `POST` rather than `GET`. – user1063287 Jul 22 '19 at 13:45
0

A 401 http error code typically means you are not able to authenticate. That means your token is either not valid or you've misconfigured how the token is given to the API. I believe the later is your problem. Based on these docs, you need to pass the token as the value to the X-Watson-Authorization-Token header not as a query parameter.

jcragun
  • 2,060
  • 10
  • 8