static void Main(string[] args) { Console.WriteLine("Hello Text to Speech!"); var builder = new ConfigurationBuilder() .AddJsonFile($"appsettings.json", true, true) .AddJsonFile($"appsettings.development.json", true, true); var configuration = builder.Build(); var key = configuration["CognitiveServices:Key"]; var endpoint = configuration["CognitiveServices:EndPoint"]; var region = endpoint.Substring(8, endpoint.IndexOf('.') - 8); var voiceShortName = configuration["CognitiveServices:PreferedVoiceShortName"]; // Create an authentication object Authentication auth = new Authentication(endpoint, key); string host = $"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1"; string path = configuration["Path"]; // Un comment if you want to save all voices available in your region //SaveAllVoices(region, auth); Voices = JsonConvert.DeserializeObject <List <Voice> >(GetAllVoices(region, auth)); Console.Write("Type the text for Nabaztag to say: "); string input = Console.ReadLine(); SaveTextToSpeechFile(host, auth, input, voiceShortName).Wait(); // Ask the rabbit to say it if (args.Length > 0) { _nabaztag = new Nabaztag.Net.Nabaztag(args[0], 10543); } else { _nabaztag = new Nabaztag.Net.Nabaztag(); } var signature = new Sequence() { AudioList = new string[] { "nabweatherd/signature.mp3" } }; var body = new Sequence[] { new Sequence() { AudioList = new string[] { $"../../../../{path}/{FileName}" } } }; var resp = _nabaztag.Message(signature, body, DateTime.MinValue); if (resp.Status == Status.Ok) { Console.WriteLine("TTS played properly"); } else { Console.WriteLine($"Something wrong happened: {resp.ErrorClass}, {resp.ErrorMessage}"); } }
public static bool InitializeConnection() { try { var ttsSetting = TtsController.LoadTtsSetting(TtsFilePathSettings); _address = ttsSetting.NabaztagAddress; _port = ttsSetting.NabaztagPort; _nabaztag = new Nabaztag.Net.Nabaztag(_address, _port); IsInitalized = true; } catch (Exception) { IsInitalized = false; } return(IsInitalized); }