0
votes

I am trying to upload audio file to Speaker Recognition from retrofit but getting the Invalid Audio Error:

please find the code below:

 public void  createEnrollment(String verficationId,String file) throws IOException {

    RequestBody videoBody = RequestBody.create(MediaType.parse("application/octet-stream"), file);
    MultipartBody.Part vFile = MultipartBody.Part.createFormData("audio", file, videoBody);

    ApiInterface service = RetrofitClientInstance.getRetrofitInstance().create(ApiInterface.class);
    Call<List<EnrolmentResult>> call = service.postAudioAndGetResponse(API_KEY,verficationId,vFile);
    call.enqueue(new Callback<List<EnrolmentResult>>() {
        @Override
        public void onResponse(Call<List<EnrolmentResult>> call, Response<List<EnrolmentResult>> response) {
            Log.d("Result", response.body().toString());
        }
        @Override
        public void onFailure(Call<List<EnrolmentResult>> call, Throwable t) {
            //progressDoalog.dismiss();
            Log.d("Error", t.getMessage());
                }
    });

}


 public interface ApiInterface {

@Multipart
@POST("identificationProfiles/{verificationProfileId}/enroll")
Call <List<EnrolmentResult>> postAudioAndGetResponse(@Header("Ocp-Apim-Subscription-Key") String keyValue,
                                                     @Path("verificationProfileId") String id,
                                                     @Part MultipartBody.Part file
                                                     );

 }

Audio is .wav format and converted to below format:

Container WAV Encoding PCM Rate 16K Sample Format 16 bit Channels Mono

When i send the same from Post Man i am getting the 202 response as Success

enter image description here

1
Maybe more details about the error would be interesting - Nicolas R
Error : 400, Bad Request - Sachin Gupta
forgot to put , Bad Request : Invalid Audio Format - Sachin Gupta

1 Answers

0
votes

Have you tried using application/json for the media type? ... looks like all calls expect this , even though we are sending binary