Skip to content

Commit

Permalink
Merge pull request #125 from Azure-Samples/UpgradeCustomVoiceAPI
Browse files Browse the repository at this point in the history
Upgrade custom voice api
  • Loading branch information
neoguo0601 authored Aug 19, 2019
2 parents e44dcb1 + 13955e2 commit 2a418d3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public static HttpResponseMessage Delete(string subscriptionKey, string url)
}
}

public static string GetToken(string authenticationPath, string subscriptionKey)
public static string GetToken(string issueTokenUrl, string subscriptionKey)
{
var ibizaStsUrl = new Uri(authenticationPath);
var ibizaStsUrl = new Uri(issueTokenUrl);
var authentication = new Authentication(ibizaStsUrl, subscriptionKey);
return authentication.RetrieveNewTokenAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public static bool Create(string subscriptionKey, string hostURI, string name, s
return true;
}

public static void Call(string subscriptionKey, string ibizaStsUrl, string endpointUrl, string voiceName, string locale, string script, string outputFile, bool isSSML)
public static void Call(string subscriptionKey, string issueTokenUrl, string endpointUrl, string voiceName, string locale, string script, string outputFile, bool isSSML)
{
const string SsmlPattern = @"<speak version=""1.0"" xmlns=""http://www.w3.org/2001/10/synthesis"" xmlns:mstts=""http://www.w3.org/2001/mstts"" xml:lang=""{0}"">" +
@"<voice name = ""{1}"">{2}</voice>" +
@"</speak>";
string ssml = "";
string token = APIHelper.GetToken(ibizaStsUrl, subscriptionKey);
string token = APIHelper.GetToken(issueTokenUrl, subscriptionKey);

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(endpointUrl);
string ImpressionGUID = Guid.NewGuid().ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static Dictionary<string, List<string>> GetParameters(APIKind apiKind, Ac
}
case nameof(APIKind.endpoint) + "-" + nameof(Action.call):
{
RequiredParameters = new List<string>() { "subscriptionKey", "ibizastsurl", "endpointUrl", "voiceName", "locale", "script", "outputFile" };
RequiredParameters = new List<string>() { "subscriptionKey", "issuetokenurl", "endpointUrl", "voiceName", "locale", "script", "outputFile" };
OptionalParameters = new List<string>() { "isSSML" };
break;
}
Expand Down
4 changes: 2 additions & 2 deletions CustomVoice-API-Samples/CSharp/CustomVoice-API/APIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private static void EndpointCreate(Dictionary<string, string> arguments)
private static void EndpointCall(Dictionary<string, string> arguments)
{
string subscriptionKey = arguments["subscriptionkey"];
string ibizaStsUrl = arguments["ibizastsurl"];
string issueTokenUrl = arguments["issuetokenurl"];
string endpointUrl = arguments["endpointurl"];
string voiceName = arguments["voicename"];
string locale = arguments["locale"];
Expand All @@ -541,7 +541,7 @@ private static void EndpointCall(Dictionary<string, string> arguments)
isSSML = Convert.ToBoolean(arguments["isssml"]);
}

Endpoint.Call(subscriptionKey, ibizaStsUrl, endpointUrl, voiceName, locale, script, outputfile, isSSML);
Endpoint.Call(subscriptionKey, issueTokenUrl, endpointUrl, voiceName, locale, script, outputfile, isSSML);
}

private static void BatchSynthesisGet(Dictionary<string, string> arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public static void PrintEndpointActionUsage(Action action, Dictionary<string, Li
case Action.call:
actionString = "endpoint call";
description = "Calling the endpoint to synthesize voice data.";
sampleCommand = "CustomVoice-API endpoint call subscriptionKey [YourSubscriptionKey] ibizastsurl https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken endpointUrl https://westus.voice.speech.microsoft.com/cognitiveservices/v1?deploymentId=xxx-xx-xx-xx-xxxxx voiceName testVoice locale en-US script 12345 outputFile C://test.wav isSSML false";
sampleCommand = "CustomVoice-API endpoint call subscriptionKey [YourSubscriptionKey] issuetokenurl https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken endpointUrl https://westus.voice.speech.microsoft.com/cognitiveservices/v1?deploymentId=xxx-xx-xx-xx-xxxxx voiceName testVoice locale en-US script 12345 outputFile C://test.wav isSSML false";
PrintActionUsageBase(actionString, description, sampleCommand, parameters);
break;
default:
Expand Down
8 changes: 5 additions & 3 deletions CustomVoice-API-Samples/CSharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Use API to construct an e2e flow: upload data, start modeling, create voice test
Before use
----------------

You must obtain a Speech API subscription key by following instructions in [Microsoft Cognitive Services subscription](<https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-apis#authentication>).
You must obtain a Speech API subscription key by following instructions in [Microsoft Cognitive Services subscription](<https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started#create-a-speech-resource-in-azure>).



Expand Down Expand Up @@ -85,9 +85,11 @@ Sample command : CustomVoice-API project get subscriptionKey [YourSubscriptionKe

#### Some parameters sets

- [IbizaStsUrl](<https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech#how-to-get-an-access-token>)
- [HostURI](<https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/regions#speech-to-text-text-to-speech-and-translation>)

- [Output Format](<https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech#audio-outputs>)
- [IssueTokenUrl](<https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech#how-to-get-an-access-token>)

- [OutputFormat](<https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech#audio-outputs>)

Contributing
============
Expand Down

0 comments on commit 2a418d3

Please sign in to comment.