private static bool SaveTextToWaveFile(string text, string filePath, IVoice voice) { if (voice is AzureVoice) { return(AzureRuntimeService.SaveStringToWaveFileWithAzureVoice(text, filePath, voice as AzureVoice)); } else if (voice is ComputerVoice) { ComputerVoiceRuntimeService.SaveStringToWaveFile(text, filePath, voice as ComputerVoice); return(true); } else if (voice is WatsonVoice) { WatsonRuntimeService.SaveStringToWaveFile(text, filePath, voice as WatsonVoice); return(true); } return(false); }
public static void LoadUserAccount() { if (!AzureAccount.GetInstance().IsEmpty()) { return; } Dictionary <string, string> user = new Dictionary <string, string>(); try { FileStream file = File.Open(GetAccessKeyFilePath(), FileMode.Open); XElement root = XElement.Load(file); foreach (XElement el in root.Elements()) { user.Add(el.Name.LocalName, el.Value); } string key = user.ContainsKey("key") ? user["key"] : null; string endpoint = user.ContainsKey("endpoint") ? user["endpoint"].Trim() : null; if (key != null && endpoint != null) { AzureAccount.GetInstance().SetUserKeyAndRegion(key, endpoint); AzureRuntimeService.IsAzureAccountPresentAndValid = AzureRuntimeService.IsValidUserAccount(errorMessage: "Invalid Azure Account." + "\nIs your Azure account expired?\nAre you connected to Wifi?"); } else { AzureRuntimeService.IsAzureAccountPresentAndValid = false; File.Delete(GetAccessKeyFilePath()); } } catch (Exception e) { AzureRuntimeService.IsAzureAccountPresentAndValid = false; Logger.Log(e.Message); } }