示例#1
0
        private static void BatchSynthesisGetvoices(Dictionary <string, string> arguments)
        {
            string subscriptionKey = arguments["subscriptionkey"];
            string hostURI         = arguments["hosturi"];

            var result = BatchSynthesis.Getvoices(subscriptionKey, hostURI);

            DisplayResult <API.DTO.Voice>(result);
        }
示例#2
0
        private static void BatchSynthesisGetById(Dictionary <string, string> arguments)
        {
            string subscriptionKey  = arguments["subscriptionkey"];
            string hostURI          = arguments["hosturi"];
            string batchSynthesisId = arguments["batchsynthesisid"];

            var result = BatchSynthesis.GetById(subscriptionKey, hostURI, batchSynthesisId);

            DisplaySingleResult(result, "  ");
        }
示例#3
0
        private static void BatchSynthesisDeleteById(Dictionary <string, string> arguments)
        {
            string subscriptionKey  = arguments["subscriptionkey"];
            string hostURI          = arguments["hosturi"];
            string batchSynthesisId = arguments["batchsynthesisid"];

            if (BatchSynthesis.DeleteById(subscriptionKey, hostURI, batchSynthesisId))
            {
                Console.WriteLine("Delete batch synthesis successfully");
            }
            else
            {
                Console.WriteLine("Delete batch synthesis failed");
            }
        }
示例#4
0
        private static void BatchSynthesisCreate(Dictionary <string, string> arguments)
        {
            string subscriptionKey     = arguments["subscriptionkey"];
            string hostURI             = arguments["hosturi"];
            string name                = arguments["name"];
            string inputTextPath       = arguments["inputtextpath"];
            string locale              = arguments["locale"];
            string models              = arguments["models"];
            string description         = name;
            string outputFormat        = "riff-16khz-16bit-mono-pcm";
            bool   isConcatenateResult = false;

            if (arguments.Keys.ToList().Contains("description"))
            {
                description = arguments["description"];
            }

            if (arguments.Keys.ToList().Contains("outputformat"))
            {
                outputFormat = arguments["outputformat"];
            }

            if (arguments.Keys.ToList().Contains("isconcatenateresult"))
            {
                isConcatenateResult = Convert.ToBoolean(arguments["isconcatenateresult"]);
            }

            var modelsList  = new List <string>(models.Split(';')).Select(x => new Guid(x)).ToList();
            var synthesisId = BatchSynthesis.Create(subscriptionKey, hostURI, name, description, inputTextPath, locale, modelsList, outputFormat, isConcatenateResult);

            if (string.IsNullOrEmpty(synthesisId))
            {
                Console.WriteLine("Create batch synthesis failed");
            }
            else
            {
                Console.WriteLine($"Create batch synthesis successfully, ID : {synthesisId}");
            }
        }
示例#5
0
        private static void BatchSynthesisGetVoices(Dictionary <string, string> arguments)
        {
            string subscriptionKey             = arguments["subscriptionkey"];
            string hostURI                     = arguments["hosturi"];
            string additionalRequestHeadersStr = arguments["additionalrequestheaders"];
            Dictionary <string, string> additionalRequestHeaders = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(additionalRequestHeadersStr))
            {
                foreach (string headerStr in additionalRequestHeadersStr.Split(';'))
                {
                    var headerKeyValue = headerStr.Split(',');
                    if (headerKeyValue.Length == 2)
                    {
                        additionalRequestHeaders.Add(headerKeyValue[0], headerKeyValue[1]);
                    }
                }
            }

            var result = BatchSynthesis.Getvoices(subscriptionKey, hostURI, additionalRequestHeaders);

            DisplayResult <API.DTO.Voice>(result);
        }
示例#6
0
        private static void BatchSynthesisGet(Dictionary <string, string> arguments)
        {
            string subscriptionKey = arguments["subscriptionkey"];
            string hostURI         = arguments["hosturi"];
            string timeStart       = string.Empty;
            string timeEnd         = string.Empty;
            string status          = string.Empty;
            int    skip            = -1;
            int    top             = -1;

            if (arguments.Keys.ToList().Contains("timestart"))
            {
                timeStart = arguments["timestart"];
                var ret = DateTime.TryParse(timeStart, out var createdTimeStart);
                if (!ret)
                {
                    Console.WriteLine("A valid timestart should be given like '2019-11-21 15:26:21'.");
                    return;
                }
            }
            if (arguments.Keys.ToList().Contains("timeend"))
            {
                timeEnd = arguments["timeend"];
                var ret = DateTime.TryParse(timeEnd, out var createdTimeEnd);
                if (!ret)
                {
                    Console.WriteLine("A valid timeend should be given like '2019-11-21 15:26:21'.");
                    return;
                }
            }
            if (arguments.Keys.ToList().Contains("status"))
            {
                status = arguments["status"];
                var ret = API.DTO.OneApiState.TryParse(status, true, out API.DTO.OneApiState apiState);
                if (!ret)
                {
                    Console.WriteLine("status parameter missing or invalid. Should be one of 'NotStarted/Running/Succeeded/Failed'.");
                }
            }
            if (arguments.Keys.ToList().Contains("skip"))
            {
                var skipParam = arguments["skip"];
                var ret       = int.TryParse(skipParam, out skip);
                if (!ret)
                {
                    Console.WriteLine("skip parameter should be an integer number.");
                }
            }
            if (arguments.Keys.ToList().Contains("top"))
            {
                var topParam = arguments["top"];
                var ret      = int.TryParse(topParam, out top);
                if (!ret)
                {
                    Console.WriteLine("top parameter should be an integer number.");
                }
            }

            var result = BatchSynthesis.Get(subscriptionKey, hostURI, timeStart, timeEnd, status, skip, top);

            DisplayResult <API.DTO.BatchSynthesis>(result);
        }