private static void SaveStringToWaveFile(string text, string filePath, WatsonVoice voice, string key, string endpoint) { Text synthesizeText = new Text { _Text = text }; TokenOptions options = new TokenOptions(); options.IamApiKey = key; var _service = new SynthesizeWatsonVoice(options, endpoint); var synthesizeResult = _service.Synthesize(synthesizeText, "audio/wav", voice: "en-US_" + voice.VoiceName); StreamUtility.SaveStreamToFile(filePath, synthesizeResult); }
public static void SaveStringToWaveFile(string text, string filePath, WatsonVoice voice) { if (!IsWatsonAccountPresentAndValid) { return; } string _key = WatsonAccount.GetInstance().GetKey(); string _endpoint = EndpointToUriConverter.watsonRegionToEndpointMapping[WatsonAccount.GetInstance().GetRegion()]; Text synthesizeText = new Text { _Text = text }; TokenOptions options = new TokenOptions(); options.IamApiKey = _key; string endpoint = _endpoint; var _service = new SynthesizeWatsonVoice(options, endpoint); var synthesizeResult = _service.Synthesize(synthesizeText, "audio/wav", voice: "en-US_" + voice.VoiceName); StreamUtility.SaveStreamToFile(filePath, synthesizeResult); }