Ejemplo n.º 1
0
        private static bool InitializeSpeechKit()
        {
            try
            {
                // initialize the SpeechKit
                // the App Key is embedded in the SpeechKit objective-C library
                // to change App Keys this library needs to be updated and recompiled
                SpeechKit.Initialize(
                    NuanceServiceInfo.SpeechKitAppId,
                    NuanceServiceInfo.SpeechKitServer,
                    NuanceServiceInfo.SpeechKitPort,
                    NuanceServiceInfo.SpeechKitSsl,
                    new NuanceSpeechKitDelegate());
            }
            catch (Exception ex)
            {
                TraceHelper.AddMessage("Exception in SpeechKitInitialize: " + ex.Message);
                return(false);
            }

            //beep = (SKEarcon) SKEarcon.FromName(p);
            string path = Path.GetFullPath("beep.wav");

            beep = new SKEarcon(path);
            SpeechKit.SetEarcon(beep, SKEarconType.SKStartRecordingEarconType);

            return(true);
        }
Ejemplo n.º 2
0
        private static bool SpeechkitInitialize()
        {
            try
            {
                _speechKit = SpeechKit.initialize(
                    NuanceServiceInfo.SpeechKitAppId,
                    NuanceServiceInfo.SpeechKitServer,
                    NuanceServiceInfo.SpeechKitPort,
                    NuanceServiceInfo.SpeechKitSsl,
                    NuanceServiceInfo.SpeechKitApplicationKey);
            }
            catch (Exception ex)
            {
                TraceHelper.AddMessage("Exception in SpeechKitInitialize: " + ex.Message);
                return(false);
            }

            _beep = _speechKit.defineAudioPrompt("beep.wav");
            _speechKit.setDefaultRecognizerPrompts(_beep, null, null, null);
            _speechKit.connect();
            Thread.Sleep(10); // to guarantee the time to load prompt resource

            return(true);
        }
Ejemplo n.º 3
0
        private bool speechkitInitialize()
        {
            try
            {
                AppInfo.SpeechKitServer = "rw.nmdp.nuancemobility.net";
                AppInfo.SpeechKitPort = 443;
            }
            catch (FormatException e)
            {
                MessageBox.Show("Port must be a number "+e);

                return false;
            }

            try
            {
                _speechKit = SpeechKit.initialize(AppInfo.SpeechKitAppId, AppInfo.SpeechKitServer, AppInfo.SpeechKitPort, AppInfo.SpeechKitSsl, AppInfo.SpeechKitApplicationKey);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);

                return false;
            }

            //_beep = _speechKit.defineAudioPrompt("beep.wav");
            _speechKit.setDefaultRecognizerPrompts(_beep, null, null, null);
            _speechKit.connect();
            Thread.Sleep(10); // to guarantee the time to load prompt resource

            return true;
        }
        private bool speechkitInitialize()
        {
            try
            {
                AppInfo.SpeechKitServer = textBoxServerIp.Text;
                AppInfo.SpeechKitPort = Convert.ToInt32(textBoxServerPort.Text);
            }
            catch (FormatException e)
            {
                MessageBox.Show("Port must be a number");

                return false;
            }

            try
            {
                _speechKit = SpeechKit.initialize(AppInfo.SpeechKitAppId, AppInfo.SpeechKitServer, AppInfo.SpeechKitPort, AppInfo.SpeechKitSsl, AppInfo.SpeechKitApplicationKey);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);

                return false;
            }

            _beep = _speechKit.defineAudioPrompt("beep.wav");
            _speechKit.setDefaultRecognizerPrompts(_beep, null, null, null);
            _speechKit.connect();
            Thread.Sleep(10); // to guarantee the time to load prompt resource

            return true;
        }
Ejemplo n.º 5
0
        private static bool SpeechkitInitialize()
        {
            try
            {
                _speechKit = SpeechKit.initialize(
                    NuanceServiceInfo.SpeechKitAppId,
                    NuanceServiceInfo.SpeechKitServer,
                    NuanceServiceInfo.SpeechKitPort,
                    NuanceServiceInfo.SpeechKitSsl,
                    NuanceServiceInfo.SpeechKitApplicationKey);
            }
            catch (Exception ex)
            {
                TraceHelper.AddMessage("Exception in SpeechKitInitialize: " + ex.Message);
                return false;
            }

            _beep = _speechKit.defineAudioPrompt("beep.wav");
            _speechKit.setDefaultRecognizerPrompts(_beep, null, null, null);
            _speechKit.connect();
            Thread.Sleep(10); // to guarantee the time to load prompt resource

            return true;
        }
        protected void cleanup()
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanup: Entered method.");
            if (currentRecognizer != null)
            {
            try
            {
                currentRecognizer.cancel();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanupSpeechKit: Error cancelling recognizer: " + e.ToString());
            }
            }
            if (vocalizerInstance != null)
            {
            try
            {
                vocalizerInstance.cancel();
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanupSpeechKit: Vocalizer cancelled.");
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanupSpeechKit: Error cancelling vocalizer: " + e.ToString());
            }
            vocalizerInstance = null;

            }

            if (speechKit != null)
            {
            try
            {
                speechKit.cancelCurrent();
                speechKit.release();
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanupSpeechKit: Speech kit released.");
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanupSpeechKit: Error releasing speech kit: " + e.ToString());
            }
            speechKit = null;
            }
        }
        /// <summary> Method to initialize speech kit</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void initSpeechKit(string args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Entered method.");

            PluginResult result = null;
            InitParameters initParams = JsonHelper.Deserialize<InitParameters>(args);

            // Get parameters to do initialization
            string credentialClassName = initParams.credentialClassName;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: Credential Class = [" + credentialClassName + "]");
            string serverName = initParams.serverName;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: Server = [" + serverName + "]");
            int port = initParams.port;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: Port = [" + port + "]");
            bool sslEnabled = initParams.sslEnabled;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: SSL = [" + sslEnabled + "]");

            ReturnObject returnObject = new ReturnObject();

            try{
            if (speechKit == null)
            {
                Type t = Type.GetType(credentialClassName);
                ICredentials credentials = (ICredentials)Activator.CreateInstance(t);

                String appId = credentials.getAppId();
                byte[] appKey = credentials.getAppKey();

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: About to initialize");
                speechKit = SpeechKit.initialize(appId, serverName, port, sslEnabled, appKey);

                //_beep = _speechKit.defineAudioPrompt("beep.wav");
                //_speechKit.setDefaultRecognizerPrompts(_beep, null, null, null);

                speechKit.connect();
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Connected.");
                Thread.Sleep(10);

            }

            setReturnCode(returnObject, RC_SUCCESS, "Init Success");
            returnObject.eventName = EVENT_INIT_COMPLETE;
            result = new PluginResult(PluginResult.Status.OK, returnObject);
            result.KeepCallback = false;
            }
            catch(Exception e){
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Error initalizing:" + e.ToString());
            setReturnCode(returnObject, RC_FAILURE, e.ToString());
            result = new PluginResult(PluginResult.Status.OK, returnObject);
            }

            DispatchCommandResult(result);
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Leaving method.");
            //return result;
        }