IBM Speech to Text service call return error - ibm-cloud

I have created IBM Speech to Text service. Then I have performed the trial call using the following IBM instructions:
Try an API call
Call the POST /v1/recognize method to request a basic transcription of
a FLAC audio file with no additional request parameters.
First, download the sample audio file audio-file.flac.
Then, issue the following command to call the service's /v1/recognize
method for basic transcription with no parameters. The example uses
the Content-Type header to indicate the type of the audio, audio/flac.
The example uses the default language model, en-US_BroadbandModel, for
transcription. Be sure to modify {path_to_file} to specify the
location of the audio-file.flac file.
curl -X POST \
-u "apikey:{apikey}" \
--header "Content-Type: audio/flac" \
--data-binary #{path_to_file}audio-file.flac \
"{url}/v1/recognize"
The service returns the following transcription results:
{
"results": [
{
"alternatives": [
{
"confidence": 0.8691191673278809,
"transcript": "several tornadoes touch down as a line of severe thunderstorms swept through colorado on sunday"
}
],
"final": true
}
],
"result_index": 0
}
I have tried execute this substituting my STT service credentials, but I received error message instead of transcript result:
<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>
An error occurred while processing your request.<p>
Reference #179.24f01502.1545478256.101ee90d
</BODY></HTML>
I have tried different {path_to_file} variants - using slashes /, backslashes \ and double backslashes \ \ but all of them returned the same error. What's wrong with my request or my STT service?

Check the location of your service - this error occures when you mix up the service urls. For example creating the service in Frankfurt
with this API URL https://stream-fra.watsonplatform.net/speech-to-text/api/v1/recognize and calling the service using the London location gateway-lon
curl -X POST \
-u "apikey:APIKEY" \
--header "Content-Type: audio/flac" \
--data-binary #audio-file.flac \
"https://gateway-lon.watsonplatform.net/speech-to-text/api/v1/recognize"
the error occures. It should probably return something like {"code":401, "error": "Unauthorized"}.

Related

How to fix this error and what does this error mean in IBM Cloud?

Now I would like to use "Speech to Text" on IBM Cloud to get Japanese text from Speech data, mp3.
However, I have gotten the same error as below after I tried it many times.
<HTML><HEAD>
<TITLE>Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error - Write</H1>
The server encountered an internal error or
misconfiguration and was unable to
complete your request.
And this is my code with curl.
curl -X POST -u "apikey:{apikey}" \
--header "Content-Type: audio/mp3" \
--data-binary #{path_to_file} \
"https://gateway-tok.watsonplatform.net/speech-t
o-text/api/v1/recognize?model=jaJP_BroadbandModel"
You have a typo in the model, it should be ja-JP_BroadbandModel
Try this code
Note that: After the {url} , you must type /v1/recognize
*audio-file.flac is the name of the audio file
curl -X POST -u "apikey:{apikey}" ^
--header "Content-Type: audio/flac" ^
--data-binary #{audio file path}audio-file.flac ^
"{url}/v1/recognize"
Happy coding :)

Why do i get 400 using AutoML Rest API?

I trained a custom model using Google Cloud AutoML.
Now i am trying to access it, using the script provided by Google.
I tried to vary "content" in any kind of ways.
I also had a look at the information provided here. Surely i did provide the correct path to the key file. Also i checked on the project ID and model ID.
I do have a service account. Billing is enabled too.
export GOOGLE_APPLICATION_CREDENTIALS={key-file-path}
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://automl.googleapis.com/v1beta1/projects/{my-project-ID}/locations/us-central1/models/{my-model-id}:predict \
-d '{
"payload" : {
"textSnippet": {
"content": "happy",
"mime_type": "text/plain"
},
}
}'
I expect the result to be the prediction.
My result looks like this:
"error": {
"code": 400,
"message": "Invalid JSON payload received. Expected a value.\n“happy”,\n \n^",
"status": "INVALID_ARGUMENT"}
Thanks for your comments, John Hanley and Phillipp Möhler!
Actually I can't really tell what happened here.
I followed Johns advice to use a whole sentence. Doing that enabled me to successfully predict something!
Afterwards I was able to use both, single words and sentences.
Deleting the commas seems to have no effect at all.

Visual Recognition error 400: Cannot execute learning task no classifier name given

I am using Visual Recognition curl command to add a classification to an image:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids=classifierlist.json" \
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classifiers?version=2015-12-02"
json file:
{
"classifiers": [
{
"name": "tomato",
"classifier_id": "tomato_1",
"created": "2016-03-23T17:43:11+00:00",
"owner": "xyz"
}
]
}
(Also tried without the classifiers array. Got the same error)
and getting an error:
{"code":400,"error":"Cannot execute learning task : no classifier name given"}
Is something wrong with the json?
To specify the classifiers you want to use you need to send a JSON object similar to:
{"classifier_ids": ["Black"]}
An example using Black as classifier id in CURL:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids={\"classifier_ids\":[\"Black\"]}"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"
If you want to list the classifier ids in a JSON file then:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids=#classifier_ids.json"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"
Where classifier_ids.json has:
{
"classifier_ids": ["Black"]
}
You can test the Visual Recognition API in the API Explorer.
Learn more about the service in the documentation.
The model schema you are referencing, and what is listed in the API reference, is the format of the response json. It is an example of how the API will return your results.
The format of the json that you use to specify classifiers should be a simple json object, as German suggests. In a file, it would be:
{
"classifier_ids": ["tomato_1"]
}
You also need to use < instead of # for the service to read the contents of the json file correctly. (And you might need to quote the < character on a command line since it has special meaning (redirect input).) So your curl would be:
curl -u "user":"password" \
-X POST \
-F "images_file=#image0.jpg" \
-F "classifier_ids=<classifier_ids.json"
"https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02"

Mashape multipart-form POST request

I have a POST method in my API which uses multipart encoded form data. I have set up the correct header and data settings so that the mashape web interface generated the following curl:
curl -X POST --include 'https://sslavov-text-analytics-v1.p.mashape.com/news' \
-H 'Authorization: Basic ***********' \
-H 'X-Mashape-Key: ************' \
-H 'Content-Type: multipart/form-data' \
-F 'file=#sample.docx' \
-F 'meta={"documentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"};type=application/json'
Basically i'm trying to upload a file with a simple paragraph of text for processing. The curious part is that when I run this exact curl in a bash script, everything works smoothly, but when I try to run it through mashape, it says either 400 Bad Request or 500 Internal Server Error
In my particular case, these errors are generated when I don't pass correct form or headers. So my question is: Is there an error in the curl syntax or should I keep looking for the error on server side?
EDIT: I figured out what the problem was. -F 'file=#sample.docx' was passed before -F 'meta....' and that was causing the 500 Internal Server Error So now the question is: Is there any way to specifically arrange the order of the form fields (because mashape rearranges them aplhabetically)?

Https Error in Postman when Send push notification via Rest

I'm fairly new To Parse with Rest Api
I wanna test samples in Their Webistes's ( Here ) in Postman But every time I Post it gives me following Authentication error :
I Wanna test following code in Postman ( see origin here )
curl -X POST \
-H "X-Parse-Application-Id: 0VoIZO8cgmnyfiuklLLkKkxOX7r" \
-H "X-Parse-REST-API-Key: UjU5eb5zjic75mPZVdHExYqnneT" \
-H "Content-Type: application/json" \
-d '{
"deviceType": "ios",
"deviceToken": "0123456789abcdef0123456789cdef0123456789abcdef",
"channels": [
""
]
}' \
https://api.parse.com/1/installations
How Can I resolve this issue ? What is that ? And What is required ?
You are reqeuesting GET request and api doc says its POST request.
1) Enter correct url and select POST request method. Add required headers as per the doc.
2) Enter raw JSON data in your request body.
3) You will receive your output. Since api key and application id is not valid so that I received unauthorized error.