Re: Problems with Functions in C#

Also here is my own class for Text to speech.
That i use in my own game.

I hope the code is not to long.
Just rename the namespace or call it from there.
Also remove the jaws and nvda options.
If you dont wish to use them.
And you must also remove the Log function from the exception catcher.
Since thats another class in my game.
Just use something else to log errors.


//Project: Luna Stories
//Class: Extra/TTSEngine.cs
//TTS Engine class for text to speech.
#region Imports
using System;
using FSAPILib;
using System.Runtime.InteropServices;
#endregion
namespace LunaStories
{
    class TTSEngine
    {
        #region DLL Imports
        [DllImport("Data\\lib\\nvdaControllerClient.dll", CharSet = CharSet.Unicode)]
        ///Speaks Text USing NVDA
        static extern long NVDASpeak(String text);
        #endregion
        #region Fields
        internal static int Volume { get; set; }
        internal static int Rate { get; set; }
        internal static int VoiceID { get; set; }
        internal static Engine SpeechEngine { get; set; }
        internal static System.Speech.Synthesis.SpeechSynthesizer DefaultEngine { get; set; }
        internal static JawsApi Jaws { get; set; }
        #endregion
        #region Enumeration
        public enum Engine
        {
            Default, NVDA, Jaws
        }
        #endregion
        #region Speak
        /// Speaks Message Using TTSEngine
        /// <summary>
        /// </summary>
        /// <param name="info">String Message</param>
        internal static void Speak(string info)
        {
            try
            {
                //Switch on engine
                switch (SpeechEngine)
                {
                    case Engine.Default:
                        if (DefaultEngine == null)
                            DefaultEngine = new System.Speech.Synthesis.SpeechSynthesizer();
                        DefaultEngine.Volume = Volume;
                        DefaultEngine.Rate = Rate;
                        DefaultEngine.SelectVoice(DefaultEngine.GetInstalledVoices()[VoiceID].VoiceInfo.Name);
                        DefaultEngine.SpeakAsyncCancelAll();
                        DefaultEngine.SpeakAsync(info);
                        break;
                    case Engine.Jaws:
                        if (Jaws == null)
                            Jaws = new JawsApi();
                        Jaws.SayString(info);
                        break;
                    case Engine.NVDA:
                        NVDASpeak(info);
                        break;
                }
            }
            catch (Exception ex)
            {
                Extra.Tools.Log(ex.ToString());
            }
        }
        #endregion
    }
}

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Xsense via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Xsense via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Xsense via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Xsense via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Xsense via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to