| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using System;
- using System.Net.ApiService;
- using System.Fire.Ini;
- using Speech.text;
- using System.Timers;
- using System.Net.HomeMatic;
- namespace Speech {
- class Program {
- // Ist verantwortlich für die Sprachsynthese, über Api Calls kann gesagt werden: "Sage Hallo", cacht die Audio-Ausgabe, ...
- // Verwaltet die Sprachtexte, Witze, Antworten, ...
- public enum eState:byte {
- Unknown,
- Stopped,
- Running,
- Starting,
- Closing,
- Updating
- }
- public static iniHandle config;
- public static eState State = eState.Stopped;
- public static eMood lastMood;
- public static Contents Jokes;
- public static Contents Weisheiten;
- public static Contents Heimauto;
- public static Contents Smalltalk;
- public static Contents Eastereggs;
- //public static HttpApiServer api;
- public static ApiServer api;
- private static Timer tmrUpdate;
- public static HMApi Homematic;
- public const int MINUTE = 60000;
- public const int SECONDS = 1000;
- static void Main(string[] args) {
- State = eState.Starting;
- Jokes = System.Fire.Serialize.Serializer.DeserializeObject<Contents>("text/jokes.bpc");
- if (Jokes == null) Jokes = new Contents();
- Weisheiten = System.Fire.Serialize.Serializer.DeserializeObject<Contents>("text/knowledge.bpc");
- if (Weisheiten == null) Weisheiten = new Contents();
- Heimauto = System.Fire.Serialize.Serializer.DeserializeObject<Contents>("text/heimauto.bpc");
- if (Heimauto == null) Heimauto = new Contents();
- Smalltalk = System.Fire.Serialize.Serializer.DeserializeObject<Contents>("text/smalltalk.bpc");
- if (Smalltalk == null) Smalltalk = new Contents();
- Eastereggs = System.Fire.Serialize.Serializer.DeserializeObject<Contents>("text/eastereggs.bpc");
- if (Eastereggs == null) Eastereggs = new Contents();
-
- config = new iniHandle("config/services.conf");
- ushort port = config["Speech"]["Port"].UInt16;
- if (port == 0)
- port = 8004;
- switch(config["Speech"]["TTS"].Value.ToLower()) {
- case "pico":
- case "picotts":
- SpeechExecute.SpeechSystem = new tts.PicoTTS();
- break;
- case "wintts":
- case "cortana":
- case "win":
- default:
- SpeechExecute.SpeechSystem = new tts.WinTTS();
- break;
- }
- switch (config["Speech"]["Play"].Value.ToLower()) {
- case "vlc":
- case "winvlc":
- default:
- SpeechExecute.PlaySystem = new play.WinVLC();
- break;
- case "aplay":
- SpeechExecute.PlaySystem = new play.aplay();
- break;
- }
- tmrUpdate = new Timer(10 * MINUTE);
- tmrUpdate.Enabled = true;
- tmrUpdate.Elapsed += TmrUpdate_Elapsed;
- tmrUpdate.Start();
- TmrUpdate_Elapsed(tmrUpdate, null);
- SpeechExecute.device = config["Speech"]["Device"].Value.ToLower();
- SpeechExecute.freq = config["Speech"]["Frequence"].Int32;
- SpeechExecute.voice = config["Speech"]["Voice"].Value;
- SpeechExecute.Init();
- string HomeMaticUrl = config["HomeMatic"]["Host"].Value;
- if (HomeMaticUrl == "") {
- System.Diagnostics.Debug.WriteLine("HomeMatic URL is empty");
- HomeMaticUrl = "http://homematic-raspi/";
- }
- Homematic = new HMApi(HomeMaticUrl); // TODO: in config auslagern
- //api = new HttpApiServer("./web", port);
- api = new ApiServer("./web", port);
- api.Request += Api_Request;
- api.RegisterClass(typeof(simple_say));
- api.Start();
- State = eState.Running;
- System.ConsoleApp.ConsoleAdvanced.Run("Speech");
- }
- private static void TmrUpdate_Elapsed(object sender, ElapsedEventArgs e) {
-
- }
- private static void Api_Request(object sender, RequestEventArgs e) {
- }
- }
- }
|