public static void ExecuteApi(APIKind apiKind, Action action, Dictionary <string, string> arguments) { try { switch (apiKind) { case APIKind.dataset: ExecuteDatasetApi(action, arguments); break; case APIKind.model: ExecuteModelApi(action, arguments); break; case APIKind.voicetest: ExecuteVoiceTestApi(action, arguments); break; case APIKind.endpoint: ExecuteEndpointApi(action, arguments); break; case APIKind.batchsynthesis: ExecuteBatchSynthesisApi(action, arguments); break; default: break; } } catch (Exception e) { Console.Error.WriteLine($"Exception: {e.Message}"); } }
public static void PrintAPIActionUsage(APIKind apiKind, Action action, Dictionary <string, List <string> > parameters) { switch (apiKind) { case APIKind.project: PrintProjectActionUsage(action, parameters); break; case APIKind.dataset: PrintDatasetActionUsage(action, parameters); break; case APIKind.model: PrintModelActionUsage(action, parameters); break; case APIKind.voicetest: PrintVoiceTestActionUsage(action, parameters); break; case APIKind.endpoint: PrintEndpointActionUsage(action, parameters); break; case APIKind.batchsynthesis: PrintBatchSynthesisActionUsage(action, parameters); break; default: break; } }
public static void ExecuteApi(APIKind apiKind, Action action, Dictionary <string, string> arguments) { switch (apiKind) { case APIKind.project: ExecuteProjectApi(action, arguments); break; case APIKind.dataset: ExecuteDatasetApi(action, arguments); break; case APIKind.model: ExecuteModelApi(action, arguments); break; case APIKind.voicetest: ExecuteVoiceTestApi(action, arguments); break; case APIKind.endpoint: ExecuteEndpointApi(action, arguments); break; case APIKind.batchsynthesis: ExecuteBatchSynthesisApi(action, arguments); break; default: break; } }
public static void PrintAPIKindUsage(APIKind apiKind) { switch (apiKind) { case APIKind.project: Console.WriteLine(""); Console.WriteLine("CustomVoice-API project:"); Console.WriteLine(""); Console.WriteLine("All Dataset, Model, VoiceTest, Endpoint are bound in the project."); Console.WriteLine("We need to specify Locale and Gender when creating Project."); Console.WriteLine("The data bound to each Project must be a unique locale and gender."); Console.WriteLine(""); Console.WriteLine("Usage: CustomVoice-API project [action] [options]"); Console.WriteLine(""); Console.WriteLine("--action"); Console.WriteLine(" Get"); Console.WriteLine(" Gets the list of projects for the authenticated subscription."); Console.WriteLine(" create"); Console.WriteLine(" Creates a new project."); Console.WriteLine(" Delete"); Console.WriteLine(" Deletes the project identified by the given ID"); Console.WriteLine(""); Console.WriteLine("For more detailed usage, please enter: CustomVoice-API project [action]"); break; case APIKind.dataset: Console.WriteLine(""); Console.WriteLine("CustomVoice-API dataset:"); Console.WriteLine(""); Console.WriteLine("Specify project upload data to create data object."); Console.WriteLine(""); Console.WriteLine("Usage: CustomVoice-API dataset [action] [options]"); Console.WriteLine(""); Console.WriteLine("--action"); Console.WriteLine(" Get"); Console.WriteLine(" Gets all voice datasets."); Console.WriteLine(" GetByProjectId"); Console.WriteLine(" Get the list of datasets for specified project."); Console.WriteLine(" Delete"); Console.WriteLine(" Deletes the voice dataset with the given id."); Console.WriteLine(" UploadDataset"); Console.WriteLine(" Uploads data and creates a new voice data object."); Console.WriteLine(" UploadDatasetWithLongAudio"); Console.WriteLine(" Upload voice dataset with long audio and scripts."); Console.WriteLine(" UploadDatasetWithAudioOnly"); Console.WriteLine(" Upload voice dataset only with audio."); Console.WriteLine(""); Console.WriteLine("For more detailed usage, please enter: CustomVoice-API dataset [action]"); break; case APIKind.model: Console.WriteLine(""); Console.WriteLine("CustomVoice-API model:"); Console.WriteLine(""); Console.WriteLine("Select data to start training model."); Console.WriteLine(""); Console.WriteLine("Usage: CustomVoice-API model [action] [options]"); Console.WriteLine(""); Console.WriteLine("--action"); Console.WriteLine(" Get"); Console.WriteLine(" Gets a list of voice model details."); Console.WriteLine(" GetByProjectId"); Console.WriteLine(" Gets the list of models for specified project."); Console.WriteLine(" Create"); Console.WriteLine(" Creates a new voice model object."); Console.WriteLine(" Delete"); Console.WriteLine(" Deletes the voice model with the given id."); Console.WriteLine(""); Console.WriteLine("For more detailed usage, please enter: CustomVoice-API model [action]"); break; case APIKind.voicetest: Console.WriteLine(""); Console.WriteLine("CustomVoice-API voicetest:"); Console.WriteLine(""); Console.WriteLine("Synthetic testing of successful training models."); Console.WriteLine(""); Console.WriteLine("Usage: CustomVoice-API voicetest [action] [options]"); Console.WriteLine(""); Console.WriteLine("--action"); Console.WriteLine(" Get"); Console.WriteLine(" Gets details of the specified model's voice test."); Console.WriteLine(" GetByProjectId"); Console.WriteLine(" Get the list of voice tests for specified project."); Console.WriteLine(" Create"); Console.WriteLine(" Creates a new voice test."); Console.WriteLine(" Delete"); Console.WriteLine(" Deletes the specified voice test."); Console.WriteLine(""); Console.WriteLine("For more detailed usage, please enter: CustomVoice-API voicetest [action]"); break; case APIKind.endpoint: Console.WriteLine(""); Console.WriteLine("CustomVoice-API endpoint:"); Console.WriteLine(""); Console.WriteLine("Deploy the model to the endpoint to invoke synthetic voice data"); Console.WriteLine(""); Console.WriteLine("Usage: CustomVoice-API endpoint [action] [options]"); Console.WriteLine(""); Console.WriteLine("--action"); Console.WriteLine(" Get"); Console.WriteLine(" Gets a list of voice endpoint details."); Console.WriteLine(" GetByProjectId"); Console.WriteLine(" Gets the list of endpoints for specified project."); Console.WriteLine(" Create"); Console.WriteLine(" Creates a new voice endpoint object."); Console.WriteLine(" Delete"); Console.WriteLine(" Delete the specified voice endpoint."); Console.WriteLine(" Call"); Console.WriteLine(" Calling the endpoint to synthesize voice data."); Console.WriteLine(""); Console.WriteLine("For more detailed usage, please enter: CustomVoice-API endpoint [action]"); break; case APIKind.batchsynthesis: Console.WriteLine(""); Console.WriteLine("CustomVoice-API batchsynthesis:"); Console.WriteLine(""); Console.WriteLine("Select supported model IDs (multiple choices) to batch generate data from scripts."); Console.WriteLine(""); Console.WriteLine("Usage: CustomVoice-API batchsynthesis [action] [options]"); Console.WriteLine(""); Console.WriteLine("--action"); Console.WriteLine(" Get"); Console.WriteLine(" Gets a list of voice synthesis under the selected subscription."); Console.WriteLine(" GetBySynthesisId"); Console.WriteLine(" Gets a voice synthesis under the selected subscription with specific ID."); Console.WriteLine(" GetVoices"); Console.WriteLine(" Gets a list of supported voices for offline synthesis."); Console.WriteLine(" Create"); Console.WriteLine(" Creates a new synthesis."); Console.WriteLine(" Delete"); Console.WriteLine(" Deletes the specified voice synthesis task."); Console.WriteLine(""); Console.WriteLine("For more detailed usage, please enter: CustomVoice-API batchsynthesis [action]"); break; default: break; } }
public static Dictionary <string, List <string> > GetParameters(APIKind apiKind, Action action) { Dictionary <string, List <string> > result = new Dictionary <string, List <string> >(); List <string> RequiredParameters = null; List <string> OptionalParameters = null; switch ($"{apiKind}-{action}") { case nameof(APIKind.dataset) + "-" + nameof(Action.uploaddataset): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, Name, ProjectId, Gender, Locale, WavePath, ScriptPath }; OptionalParameters = new List <string>() { Description }; break; } case nameof(APIKind.dataset) + "-" + nameof(Action.uploaddatasetwithlongaudio): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, Name, ProjectId, Gender, Locale, WavePath, ScriptPath }; OptionalParameters = new List <string>() { Description }; break; } case nameof(APIKind.dataset) + "-" + nameof(Action.uploaddatasetwithaudioonly): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, Name, ProjectId, Gender, Locale, WavePath }; OptionalParameters = new List <string>() { Description }; break; } case nameof(APIKind.dataset) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.dataset) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ProjectId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.dataset) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, DatasetId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, Name, ProjectId, Gender, Locale, DatasetIdList }; OptionalParameters = new List <string>() { Description, "isNeuralTTS", "isMixlingual", "purpose", "am", "amSteps", "amCheckpointInterval", "vocoderSteps", "vocoderCheckpointInterval" }; break; } case nameof(APIKind.model) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ProjectId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ModelId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ProjectId, ModelId, "script" }; OptionalParameters = new List <string>() { "isSSML" }; break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ModelId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ProjectId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, VoiceTestId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, Name, Locale, ProjectId, ModelId }; OptionalParameters = new List <string>() { Description }; break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ProjectId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.getbysynthesisid): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, BatchSynthesisId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, EndpointId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.call): { RequiredParameters = new List <string>() { SubscriptionKey, "issuetokenurl", "endpointUrl", "voiceName", Locale, "script", "outputFile" }; OptionalParameters = new List <string>() { "isSSML" }; break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, Name, "inputTextPath", Locale, "models" }; OptionalParameters = new List <string>() { Description, "outputFormat", "isConcatenateResult" }; break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.getvoices): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, BatchSynthesisId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.addtoproject): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ModelId, ProjectId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.removefromproject): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ModelId, ProjectId }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.copy): { RequiredParameters = new List <string>() { SubscriptionKey, HostUri, ModelId, "targetSubscriptionKey" }; OptionalParameters = new List <string>(); break; } default: { return(null); } } result.Add("Required", RequiredParameters.Select(x => x.ToLower()).ToList()); result.Add("Optional", OptionalParameters.Select(x => x.ToLower()).ToList()); return(result); }
public static Dictionary <string, List <string> > GetParameters(APIKind apiKind, Action action) { Dictionary <string, List <string> > result = new Dictionary <string, List <string> >(); List <string> RequiredParameters = null; List <string> OptionalParameters = null; switch ($"{apiKind}-{action}") { case nameof(APIKind.project) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "name", "gender", "locale" }; OptionalParameters = new List <string>() { "description" }; break; } case nameof(APIKind.project) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.project) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "projectId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.dataset) + "-" + nameof(Action.uploaddataset): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "name", "projectId", "gender", "locale", "wavePath", "scriptPath" }; OptionalParameters = new List <string>() { "description" }; break; } case nameof(APIKind.dataset) + "-" + nameof(Action.uploaddatasetwithlongaudio): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "name", "projectId", "gender", "locale", "wavePath", "scriptPath" }; OptionalParameters = new List <string>() { "description" }; break; } case nameof(APIKind.dataset) + "-" + nameof(Action.uploaddatasetwithaudioonly): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "name", "projectId", "gender", "locale", "wavePath" }; OptionalParameters = new List <string>() { "description" }; break; } case nameof(APIKind.dataset) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.dataset) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "projectId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.dataset) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "datasetId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "name", "projectId", "gender", "locale", "dataset" }; OptionalParameters = new List <string>() { "description", "isNeuralTTS", "isMixlingual" }; break; } case nameof(APIKind.model) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "projectId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.model) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "modelId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "projectId", "modelId", "script" }; OptionalParameters = new List <string>() { "isSSML" }; break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "modelId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "projectId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.voicetest) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "voiceTestId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "name", "locale", "projectId", "modelId" }; OptionalParameters = new List <string>() { "description" }; break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.getbyprojectid): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "projectId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "endpointId" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.endpoint) + "-" + nameof(Action.call): { RequiredParameters = new List <string>() { "subscriptionKey", "issuetokenurl", "endpointUrl", "voiceName", "locale", "script", "outputFile" }; OptionalParameters = new List <string>() { "isSSML" }; break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.create): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "name", "inputTextPath", "locale", "models" }; OptionalParameters = new List <string>() { "description", "outputFormat", "isConcatenateResult" }; break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.get): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.getvoices): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI" }; OptionalParameters = new List <string>(); break; } case nameof(APIKind.batchsynthesis) + "-" + nameof(Action.delete): { RequiredParameters = new List <string>() { "subscriptionKey", "hostURI", "batchSynthesisId" }; OptionalParameters = new List <string>(); break; } default: { return(null); } } result.Add("Required", RequiredParameters.Select(x => x.ToLower()).ToList()); result.Add("Optional", OptionalParameters.Select(x => x.ToLower()).ToList()); return(result); }