简体   繁体   English

Azure 认知服务 - TTS

[英]Azure Cognitive services - TTS

I got an api keys for Azure Cognitive services, but I can't find any documentation how I am calling this service through postmen.我获得了 Azure 认知服务的 api 密钥,但找不到任何文档,说明我如何通过邮递员调用此服务。 Anybody has experience with this?有人有这方面的经验吗?

Seems you are trying to call Text To Speech service with your keys.似乎您正在尝试使用您的密钥调用Text To Speech服务。 There are two steps for that.有两个步骤。

1. Need Access Token 1. 需要访问令牌

You have to get your token like this format:您必须以这种格式获取令牌:

Request URL: https://YourResourceEndpoint/sts/v1.0/issuetoken
Method: POST
Hearder: Content-Type:application/x-www-form-urlencoded
Ocp-Apim-Subscription-Key:YourKeys

See The Screen shot for clarity:为清楚起见,请参阅屏幕截图:

在此处输入图片说明

Code Snippet:代码片段:

public async Task<string> GetSpeechServiceToken()
        {
            try
            {
                string tokenUrl = $"https://YourServiceURL.cognitiveservices.azure.com/sts/v1.0/issuetoken";
                var tokenRequest = new HttpRequestMessage(HttpMethod.Post, tokenUrl);
                tokenRequest.Headers.Add("Ocp-Apim-Subscription-Key", "subscriptionKey");
                using (var client = new HttpClient())
                {
                    var tokenResponse = await client.SendAsync(tokenRequest);

                    var token = await tokenResponse.Content.ReadAsStringAsync();

                    return token;
                }

            }
            catch (Exception ex)
            {

                ex.Message.ToString();
            }
            return null;

        }

You could have a look on official Docs你可以看看官方文档

2. Get List Of Voices With Token You Have Received Earlier 2.获取您之前收到的带有令牌的声音列表

You can request for Text To Speech voice list Like below:您可以请求Text To Speech语音列表,如下所示:

Request URL: https://centralus.tts.speech.microsoft.com/cognitiveservices/voices/list
Method : GET
Authorization: Bearer Token Paste Your Token Here

See the screen shot for clarity为清楚起见,请参阅屏幕截图

在此处输入图片说明

You could find more details here您可以在此处找到更多详细信息

Note: In case of your test account You can create here注意:如果是您的测试帐户,您可以在此处创建

在此处输入图片说明

Update:更新:

I would sent a request and somehow I got an uri or something where I can hear it?我会发送一个请求,不知何故我得到了一个 uri 或者我可以听到的东西? is this possible?这可能吗?

Yeah its possible.是的,它可能。 But in that case you have to use sdk.但在这种情况下,您必须使用 sdk。 Here Is the complete sample .这是完整的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM