SpeechModule - Found it was very easy to extend.

Sep 28, 2009 at 7:54 PM
Very easy to add your own domain specific language constructs.  Here one I quickly put together for adding speech. 
SpeechModule.cs
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using Conscript.Compiler;
using Conscript.Runtime;
using SpeechLib;

/*
 Add Microsoft Speech Object Library (COM) - Add a reference to the ConscriptModules project. 
 and the dependent Interop.SpeechLib.dll is accessible at script runtime.
 
 Conscript Usage Example:
 
    // speechRate ranges from -10 to 10.
    set_speech_rate(-5);
    // volume ranging from 0 to 100
    set_speech_volume(30);
    var someTextToSay = "Hello World";
    say_text(someTextToSay);
*/
namespace Conscript.Modules
{
    public class SpeechModule : HostModule
    {
        
        #region Private Static Variables

        private static ReadOnlyCollection<HostFunctionPrototype> s_listHostFunctionPrototypes;
        private static SpVoice m_spVoice = new SpVoice();

        #endregion


         public SpeechModule()
        {
            Type typeBool = typeof(bool);
            Type typeString = typeof(string);
            Type typeInt = typeof(int);

            if (s_listHostFunctionPrototypes != null) return;
             
            List<HostFunctionPrototype> listHostFunctionPrototypes = new List<HostFunctionPrototype>();
            HostFunctionPrototype hostFunctionPrototype = null;

            hostFunctionPrototype = new HostFunctionPrototype(typeBool, "say_text", typeString);
            listHostFunctionPrototypes.Add(hostFunctionPrototype);
            hostFunctionPrototype = new HostFunctionPrototype(typeBool, "set_speech_volume", typeInt);
            listHostFunctionPrototypes.Add(hostFunctionPrototype);
            hostFunctionPrototype = new HostFunctionPrototype(typeBool, "set_speech_rate", typeInt);
            listHostFunctionPrototypes.Add(hostFunctionPrototype);

            s_listHostFunctionPrototypes = listHostFunctionPrototypes.AsReadOnly();
         }


        #region Public Properties

        public ReadOnlyCollection<HostFunctionPrototype> HostFunctionPrototypes
        {
            get
            {
                return s_listHostFunctionPrototypes;
            }
        }

        #endregion


        public object OnHostFunctionCall(String strFunctionName, List<object> listParameters)
        {
            switch (strFunctionName)
            {
                case "say_text":
                    m_spVoice.Speak((string)listParameters[0], SpeechVoiceSpeakFlags.SVSFlagsAsync);
                    break;
                case "set_speech_volume":
                    m_spVoice.Volume = (int)listParameters[0];
                    break;
                case "set_speech_rate":
                    m_spVoice.Rate = (int)listParameters[0];
                    break;

                 default:
                    return false;
            }

            return true;
        }
    }
}

Feb 23, 2011 at 9:08 PM

In hindsight, I could have used reflection to let users hook static methods directly without the need for wrappers. I'm afraid I don't have time to develop this further for the time being.