Search code examples
ibm-watsonvisual-recognition

How to set the desired output language in the request for visual recognition in watson?


Following is the java code for visual recognition in IBM watson and it works perfectly fine as English as default o/p language.

Now, I want to set Spanish as o/p language. How to do that? How to set the parameter?

VisualRecognition service = new VisualRecognition(VisualRecognition.VERSION_DATE_2016_05_20);
service.setApiKey(key);
ClassifyImagesOptions options = new ClassifyImagesOptions.Builder()
.images(new File(path))
.build();
VisualClassification result = service.classify(options).execute();

Solution

  • You should add acceptLanguage to your options building:

    ClassifyImagesOptions options = new ClassifyImagesOptions.Builder()
    .acceptLanguage("es")
    .images(new File(path))
    .build()