0

我是一名使用 C# 进行语音相关项目的学生。

我已经使用 Azure Bing Speech API 和 Google Cloud Speech API 将人们的声音作为文本获取。

但我还需要 Azure Speaker Recognition API 来识别和验证使用语音的单个扬声器。

但是,即使 Google 搜索,也没有太多关于此 API 的信息。而 Azure 站点(尤其是使用包含用户语音的 wav 文件识别和验证扬声器的部分)是如此简单......

我不知道如何加载 wav 文件来识别和验证 C# 代码中的扬声器。

如何使用 Azure Speaker Recognition API 做到这一点?

我试过的:

以下是Azure 站点上的示例代码。

static async void MakeRequest()
{

    var client = new HttpClient();
    var queryString = HttpUtility.ParseQueryString(string.Empty);

    // Request headers
    client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "subscription-key");

    // Request parameters
     queryString["shortAudio"] = "true";

    var uri = "https://westus.api.cognitive.microsoft.com/spid/v1.0/identify?identificationProfileIds={identificationProfileIds}&" + queryString;

    HttpResponseMessage response;

    // Request body
    byte[] byteData = Encoding.UTF8.GetBytes("{body}");

    using (var content = new ByteArrayContent(byteData))
    {
        content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

        response = await client.PostAsync(uri, content);

    }

}
4

1 回答 1

0

对于 Azure 站点上的代码片段,您始终需要替换表单的占位符,因此在您的情况下,您需要为和{something}填写适当的值。此外,内容类型必须是or , not 。identificationProfileIdsbodyapplication/octet-streammultipart/form-dataapplication/json

通过使用预构建的客户端SDK,您将节省大量输入。您还可以查看该 SDK 的源代码,例如identifyAsync,了解如何构造 HTTP 请求。

于 2018-01-11T17:23:11.217 回答