Azure 认知服务 - TTS [英] Azure Cognitive services - TTS

查看:21
本文介绍了Azure 认知服务 - TTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我获得了 Azure 认知服务的 api 密钥,但找不到任何文档,说明我如何通过邮递员调用此服务.有人有这方面的经验吗?

解决方案

似乎您正在尝试使用您的密钥调用 Text To Speech 服务.有两个步骤.

1.需要访问令牌

您必须以这种格式获取令牌:

请求 URL:https://YourResourceEndpoint/sts/v1.0/issuetoken方法:POST听者:内容类型:应用程序/x-www-form-urlencodedOcp-Apim-Subscription-Key:YourKeys

请参阅屏幕截图以了解清楚:

代码片段:

public async Task获取语​​音服务令牌(){尝试{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");使用 (var client = new HttpClient()){var tokenResponse = await client.SendAsync(tokenRequest);var token = await tokenResponse.Content.ReadAsStringAsync();返回令牌;}}捕获(异常前){ex.Message.ToString();}返回空;}

您可以查看

您可以找到更多详细信息

更新:

我会发送一个请求,但不知何故我得到了一个 uri 或其他我可以听到的东西?这可能吗?

是的,有可能.但在这种情况下,您必须使用 sdk.这是完整示例.>

I got an api keys for Azure Cognitive services, but I can't find any documentation how I am calling this service through postmen. Anybody has experience with this?

解决方案

Seems you are trying to call Text To Speech service with your keys. There are two steps for that.

1. Need Access Token

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

You can request for Text To Speech voice list Like below:

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? is this possible?

Yeah its possible. But in that case you have to use sdk. Here Is the complete sample.

这篇关于Azure 认知服务 - TTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆