Microsoft Cognitive-SpeakerRecognition BadRequst using Java
<p>I was just playing around with the Cognitive-SpeakerRecognition and tried to enroll a new user. For that i followed the examples from the Microsoft <a href="https://dev.projectoxford.ai/docs/services/563309b6778daf02acc0a508/operations/5645c3271984551c84ec6797" rel="nofollow noreferrer">API Reference</a>. Sadly I get an error response:</p>

<pre><code>{
  "error": {
    "code": "BadRequest",
    "message": "Invalid Audio Format: Not a WAVE file - no RIFF header"
  }
}
</code></pre>

<p>I spent a lot of time googleing the problem and found something related on <a href="https://github.com/Microsoft/ProjectOxford-ClientSDK/issues/66" rel="nofollow noreferrer">github</a> and <a href="https://stackoverflow.com/questions/37274645/speaker-recognition-bad-request-error-on-microsoft-oxford">StackOverflow</a>. Unfortunately, I was not able to adapt the answer from github (They fixed the problem with a longer audio example, I tried but still getting the error response). So can someone figure out what I am doing wrong? Thanks for reading :) Here is my code:</p>

<pre><code> public static void main(String[] args) {
        HttpClient httpclient = HttpClients.createDefault();

        try {
            URIBuilder builder = new URIBuilder("https://api.projectoxford.ai/spid/v1.0/identificationProfiles/{PROFIL}/enroll");

            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "multipart/form-data");
            request.setHeader("Ocp-Apim-Subscription-Key", "API_KEY");

            FileInputStream someStream = new FileInputStream(new File("test.wav"));
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            int bytesRead;
            byte[] bytes = new byte[1024];
            while ((bytesRead = someStream.read(bytes)) &gt; 0) {
                byteArrayOutputStream.write(bytes, 0, bytesRead);
            }
            byte[] data = byteArrayOutputStream.toByteArray();

            MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
            entityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
            entityBuilder.setStrictMode();
            entityBuilder.addBinaryBody("enrollmentData", data, ContentType.MULTIPART_FORM_DATA, "test.wav");
            request.setEntity(entityBuilder.build());

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) {
                System.out.println(EntityUtils.toString(entity));
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
</code></pre>

<p><strong>EDIT:</strong> Here you can download the file <a href="http://www.filedropper.com/test_120" rel="nofollow noreferrer">test.wav</a></p>