コード例 #1
0
        private void Load_Settings()
        {
            try
            {
                try
                {
                    gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value);
                }
                catch
                {
                    Log.Error("I think the Debug property is missing from the Speech object type!");
                }
                Log.Info("Debug Mode Set to " + gDebug);
                gSelectedVoice = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Voice").Value;
                OSAEObjectPropertyManager.ObjectPropertyArrayDeleteAll(gAppName, "Voices");
                foreach (System.Speech.Synthesis.InstalledVoice i in oSpeech.GetInstalledVoices())
                {
                    if (gSelectedVoice == "")
                    {
                        gSelectedVoice = i.VoiceInfo.Name;
                        OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Voice", gSelectedVoice, "SPEECH");
                        Log.Info("Default Voice Set to " + gSelectedVoice);
                    }
                    Log.Info("Adding Voice: " + i.VoiceInfo.Name);
                    OSAEObjectPropertyManager.ObjectPropertyArrayAdd(gAppName, "Voices", i.VoiceInfo.Name, "Voice");
                }

                if (gSelectedVoice != "")
                {
                    oSpeech.SelectVoice(gSelectedVoice);
                    Log.Info("Current Voice Set to " + gSelectedVoice);
                }

                // Load the speech rate, which must be -10 to 10, and set it to 0 if it is not valid.
                Int16 iTTSRate = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Rate").Value);
                if (iTTSRate < -10 || iTTSRate > 10)
                {
                    iTTSRate = 0;
                    OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "TTS Rate", iTTSRate.ToString(), gAppName);
                    Log.Info("TTS Rate was invalid! I changed it to " + iTTSRate.ToString());
                }
                Log.Info("TTS Rate Set to " + iTTSRate.ToString());
                oSpeech.Rate = iTTSRate;

                Int16 iTTSVolume = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Volume").Value);
                if (iTTSVolume < -10 || iTTSVolume > 10)
                {
                    iTTSVolume = 0;
                    OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "TTS Volume", iTTSVolume.ToString(), gAppName);
                    Log.Info("TTS Volume was invalid! I changed it to " + iTTSVolume.ToString());
                }
                oSpeech.Rate = iTTSVolume;
                Log.Info("TTS Volume Set to " + iTTSVolume.ToString());
            }
            catch (Exception ex)
            {
                Log.Error("Error in Load_Settings!", ex);
            }
        }
コード例 #2
0
        private void Load_Settings()
        {
            try
            {
                gSelectedVoice = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Voice").Value;
                OSAEObjectPropertyManager.ObjectPropertyArrayDeleteAll(gAppName, "Voices");
                foreach (System.Speech.Synthesis.InstalledVoice i in oSpeech.GetInstalledVoices())
                {
                    if (gSelectedVoice == "")
                    {
                        gSelectedVoice = i.VoiceInfo.Name;
                        OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Voice", gSelectedVoice, "SPEECH");
                        logging.AddToLog("Default Voice Set to " + gSelectedVoice, true);
                    }
                    logging.AddToLog("Adding Voice: " + i.VoiceInfo.Name, false);
                    OSAEObjectPropertyManager.ObjectPropertyArrayAdd(gAppName, "Voices", i.VoiceInfo.Name, "Voice");
                }

                if (gSelectedVoice != "")
                {
                    oSpeech.SelectVoice(gSelectedVoice);
                    logging.AddToLog("Current Voice Set to " + gSelectedVoice, true);
                }

                Int16 iTTSRate = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Rate").Value);
                if (iTTSRate > 0 && iTTSRate <= 100)
                {
                    oSpeech.Rate = iTTSRate;
                    logging.AddToLog("TTS Rate Set to " + iTTSRate.ToString(), true);
                }

                Int16 iTTSVolume = Convert.ToInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "TTS Volume").Value);
                if (iTTSVolume > -11 && iTTSVolume <= 11)
                {
                    oSpeech.Rate = iTTSVolume;
                    logging.AddToLog("TTS Rate Set to " + iTTSVolume.ToString(), true);
                }
            }
            catch (Exception ex)
            {
                logging.AddToLog("Error in Load_Voices!", true);
                logging.AddToLog("- " + ex.Message.ToString(), true);
            }
        }
コード例 #3
0
        public void updateFeeds()
        {
            this.Log.Debug("Trying to get all feed Urls:" + pName);

            DataSet ds = new DataSet();

            ds = OSAEObjectPropertyManager.ObjectPropertyArrayGetAll(pName, "Feeds");
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                try
                {
                    this.Log.Debug("Fetching feed: " + dr["item_name"].ToString());
                    WebClient webClient = new WebClient();
                    string    strSource = webClient.DownloadString(dr["item_name"].ToString());
                    webClient.Dispose();

                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(strSource);

                    string feedTitle = xml.SelectSingleNode("/rss/channel/title").InnerText;
                    this.Log.Debug("Feeds title: " + feedTitle);
                    if (OSAEObjectPropertyManager.GetObjectPropertyValue(pName, feedTitle).Value == "")
                    {
                        this.Log.Debug("Adding property to object type");
                        OSAEObjectTypeManager.ObjectTypePropertyAdd(feedTitle, "List", "", "RSS", false);
                    }
                    OSAEObjectPropertyManager.ObjectPropertyArrayDeleteAll(pName, feedTitle);
                    this.Log.Debug("Cleared feed data");

                    XmlNodeList xnList = xml.SelectNodes("/rss/channel/item");
                    foreach (XmlNode xn in xnList)
                    {
                        string content = xn.SelectSingleNode("title").InnerText + " - " + xn.SelectSingleNode("description").InnerText;
                        content = Regex.Replace(content, "<.*?>", string.Empty);
                        this.Log.Debug("Added item to feed data: " + content);
                        OSAEObjectPropertyManager.ObjectPropertyArrayAdd(pName, feedTitle, content, "");
                    }
                }
                catch (Exception ex)
                {
                    this.Log.Error("Error", ex);
                }
            }
        }
コード例 #4
0
 protected void btnListItemSave_Click(object sender, EventArgs e)
 {
     OSAEObjectPropertyManager.ObjectPropertyArrayAdd(hdnSelectedObjectName.Text, hdnSelectedPropName.Text, txtListItem.Text, txtListItemLabel.Text);
     hdnEditingPropList.Value = "1";
     loadPropertyList();
 }
コード例 #5
0
 protected void btnListItemSave_Click(object sender, EventArgs e)
 {
     OSAEObjectPropertyManager.ObjectPropertyArrayAdd(gvObjects.DataKeys[gvObjects.SelectedIndex]["object_name"].ToString(), hdnSelectedPropName.Text, txtListItem.Text, txtListItemLabel.Text);
     hdnEditingPropList.Value = "1";
     loadPropertyList();
 }