Microsoft认知语音演讲者识别无法创建注册

时间:2019-01-08 07:50:38

标签: microsoft-cognitive

请在下面为我的问题提供帮助。

我尝试使用here

中的示例代码创建一个注册
private async Task<HttpResponseMessage> MakeRequest()
    {
        string path = @"<path_to_wav_file>";
        var client = new HttpClient();
        var queryString = HttpUtility.ParseQueryString(string.Empty);

        // Request headers
        client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "<my_key>");

        // Request parameters
        queryString["shortAudio"] = "true";
        queryString["identificationProfileId"] = "<my_profile_id>";
        var uri = "https://westus.api.cognitive.microsoft.com/spid/v1.0/identificationProfiles/<my_profile_id>/enroll?" + queryString;

        HttpResponseMessage response;

        // Request body
        byte[] byteData = File.ReadAllBytes(path);

        using (var content = new ByteArrayContent(byteData))
        {
            content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            response = await client.PostAsync(uri, content);
        }

        return response;
    }

得到回应

  

{状态代码:202,ReasonPhrase:“已接受”,版本:1.1,内容:   System.Net.Http.StreamContent,标题:{语法:无缓存
  操作地点:   https://westus.api.cognitive.microsoft.com/spid/v1.0/operations/af54c843-8df9-4511-8d65-4825ebec024d   apim-request-id:37567cff-d259-4a1d-82fc-9fc884edcfe3
  严格的运输安全性:max-age = 31536000; includeSubDomains;   预加载x-content-type-options:nosniff缓存控制:no-cache
  日期:周二,2019年1月8日07:12:05 GMT X-AspNet版本:4.0.30319
  X技术支持:ASP.NET内容长度:0有效期:-1}}

  

{“错误”:{“代码”:“未指定”,“消息”:“由于无效而被拒绝访问   订阅密钥。确保您已订阅API   尝试调用并提供正确的密钥。“}}

错误消息很奇怪,因为我使用了成功创建配置文件的相同订阅密钥。

1 个答案:

答案 0 :(得分:1)

我认为您在向以下用户提出请求时应该使用(“ Ocp-Apim-Subscription-Key”,“”) https://api.projectoxford.ai/spid/v1.0/operations/af54c843-8df9-4511-8d65-4825ebec024d