Microsoft认知说话者识别API-注册-无效的音频400错误

时间:2020-04-14 20:01:39

标签: android microsoft-cognitive speaker

我正在尝试通过翻新将音频文件上传到“说话人识别”,但出现无效音频错误:

请找到以下代码:

 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
                                                     );

 }

音频为.wav格式,并转换为以下格式:

容器WAV 编码PCM 速率16K 样本格式16位 单声道频道

当我从邮递员发送邮件时,我收到202响应,表示成功

enter image description here

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用application / json作为媒体类型? ...看起来所有调用都希望这样做,即使我们正在发送二进制文件