public void Synthesize() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.Synthesize( text: "Hello, welcome to the Watson dotnet SDK!", accept: "audio/wav", voice: "en-US_AllisonVoice" ); // Save file using (FileStream fs = File.Create("synthesize.wav")) { result.Result.WriteTo(fs); fs.Close(); result.Result.Close(); } Console.WriteLine(result.Result); }
private static void Main(string[] args) { string credentials = string.Empty; #region Get Credentials string _endpoint = string.Empty; string _username = string.Empty; string _password = string.Empty; if (string.IsNullOrEmpty(credentials)) { var parentDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.FullName; string credentialsFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "credentials.json"; if (File.Exists(credentialsFilepath)) { try { credentials = File.ReadAllText(credentialsFilepath); credentials = Utility.AddTopLevelObjectToJson(credentials, "VCAP_SERVICES"); } catch (Exception e) { throw new Exception(string.Format("Failed to load credentials: {0}", e.Message)); } VcapCredentials vcapCredentials = JsonConvert.DeserializeObject <VcapCredentials>(credentials); var vcapServices = JObject.Parse(credentials); Credential credential = vcapCredentials.GetCredentialByname("text-to-speech-sdk")[0].Credentials; _endpoint = credential.Url; _username = credential.Username; _password = credential.Password; } else { Console.WriteLine("Credentials file does not exist. Please define credentials."); _username = ""; _password = ""; _endpoint = ""; } } #endregion string _synthesizeText = "Hello, welcome to the Watson dotnet SDK!"; Text synthesizeText = new Text { _Text = _synthesizeText }; var _service = new TextToSpeechService(_username, _password); _service.SetEndpoint(_endpoint); // MemoryStream Result with .wav data var synthesizeResult = _service.Synthesize(synthesizeText, "audio/wav"); Console.ReadKey(); }
public void ListVoices() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.ListVoices(); Console.WriteLine(result.Result); }
public void GetVoice() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.GetVoice("en-US_AllisonVoice"); Console.WriteLine(result.Result); }
private void ListWords() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.ListWords( customizationId: customizationId ); Console.WriteLine(result.StatusCode); }
public void DeleteUserData() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.DeleteUserData( customerId: "customerId" ); Console.WriteLine(result.StatusCode); }
public void DeleteVoiceModel() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.DeleteVoiceModel( customizationId: customizationId ); Console.WriteLine(result.StatusCode); }
private void DeleteWord() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.DeleteWord( customizationId: customizationId, word: "hello" ); Console.WriteLine(result.StatusCode); }
public void GetPronunciation() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.GetPronunciation( text: "IBM", voice: "en-US_AllisonVoice", format: "ipa" ); Console.WriteLine(result.Result); }
private void AddWord() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.AddWord( customizationId: customizationId, word: "IBM", translation: "eye bee m", partOfSpeech: "noun" ); Console.WriteLine(result.StatusCode); }
public void CreateVoiceModel() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var result = service.CreateVoiceModel( name: "dotnet-sdk-voice-model", language: "en-US", description: "Custom voice model for .NET SDK examples."); customizationId = result.Result.CustomizationId; Console.WriteLine(result.Result); }
public void Setup() { #region Get Credentials if (string.IsNullOrEmpty(credentials)) { var parentDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.FullName; string credentialsFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "credentials.json"; if (File.Exists(credentialsFilepath)) { try { credentials = File.ReadAllText(credentialsFilepath); credentials = Utility.AddTopLevelObjectToJson(credentials, "VCAP_SERVICES"); } catch (Exception e) { throw new Exception(string.Format("Failed to load credentials: {0}", e.Message)); } } else { Console.WriteLine("Credentials file does not exist."); } VcapCredentials vcapCredentials = JsonConvert.DeserializeObject <VcapCredentials>(credentials); var vcapServices = JObject.Parse(credentials); Credential credential = vcapCredentials.GetCredentialByname("text-to-speech-sdk")[0].Credentials; endpoint = credential.Url; apikey = credential.IamApikey; } #endregion TokenOptions tokenOptions = new TokenOptions() { IamApiKey = apikey, ServiceUrl = endpoint }; service = new TextToSpeechService(tokenOptions); service.SetEndpoint(endpoint); }
public void UpdateVoiceModel() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var words = new List <Word>() { new Word() { _Word = "hello", Translation = "hullo" }, new Word() { _Word = "goodbye", Translation = "gbye" }, new Word() { _Word = "hi", Translation = "ohioooo" } }; var result = service.UpdateVoiceModel( customizationId: customizationId, name: "dotnet-sdk-voice-model-updated", description: "Custom voice model for .NET SDK integration tests. Updated.", words: words ); Console.WriteLine(result.Result); }
private void AddWords() { IamConfig config = new IamConfig( apikey: apikey ); TextToSpeechService service = new TextToSpeechService(config); service.SetEndpoint(url); var words = new List <Word>() { new Word() { _Word = "hello", Translation = "hullo" }, new Word() { _Word = "goodbye", Translation = "gbye" }, new Word() { _Word = "hi", Translation = "ohioooo" } }; var result = service.AddWords( customizationId: customizationId, words: words ); Console.WriteLine(result.StatusCode); }