public static async Task RecognizeSpeechAsync(Wakeup wakeup, Bot bot) { string informations = ""; string commandes = ""; string resultat = ""; //wakeup.magicWord = "hey carl"; // Creates an instance of a speech config with specified subscription key and service region. // Replace with your own subscription key and service region (e.g., "westus"). var config = SpeechConfig.FromSubscription("feac160ac00d466b970fee69c0c513eb", "westus"); // Creates a speech recognizer. using (var recognizer = new SpeechRecognizer(config)) { Console.WriteLine("Say something..."); // Performs recognition. RecognizeOnceAsync() returns when the first utterance has been recognized, // so it is suitable only for single shot recognition like command or query. For long-running // recognition, use StartContinuousRecognitionAsync() instead. var result = await recognizer.RecognizeOnceAsync(); // Checks result. if (result.Reason == ResultReason.RecognizedSpeech) { Console.WriteLine($"We recognized: {result.Text}"); informations = result.Text.ToLower(); if (wakeup.Ecouter(informations)) { commandes = wakeup.AvoirCommandes(informations); if (commandes == "") { commandes = wakeup.AffirmationPrecedente; wakeup.AffirmationPrecedente = ""; } bot.GetMessage(commandes); resultat = bot.Identifier(); bot.Executer(resultat, wakeup); } } else if (result.Reason == ResultReason.NoMatch) { Console.WriteLine($"NOMATCH: Speech could not be recognized."); } else if (result.Reason == ResultReason.Canceled) { var cancellation = CancellationDetails.FromResult(result); Console.WriteLine($"CANCELED: Reason={cancellation.Reason}"); if (cancellation.Reason == CancellationReason.Error) { Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}"); Console.WriteLine($"CANCELED: ErrorDetails={cancellation.ErrorDetails}"); Console.WriteLine($"CANCELED: Did you update the subscription info?"); } } } }
/// <summary> /// Wakeup the Nabaztag /// </summary> /// <param name="needRequestId">true if you want a confirmation, by default, yes</param> /// <param name="cancelAfterSeconds">Cancel waiting for the answer after the seconds defined. By default, it will wait indefinitely</param> /// <returns>Response object</returns> public Response Wakeup(bool needRequestId = true, int cancelAfterSeconds = -1) { var wakeup = new Wakeup(); Guid reqId; if (needRequestId) { reqId = Guid.NewGuid(); _LastRequestId.Add(reqId.ToString(), null); wakeup.RequestId = reqId.ToString(); } return(SendMessageProcessResponse(JsonConvert.SerializeObject(wakeup), reqId, cancelAfterSeconds)); }
static void Main(string[] args) { Wakeup wakeup = new Wakeup(); Bot bot = new Bot(); wakeup.magicWord = "hey carl"; Console.WriteLine("Please press a key to continue."); Console.ReadLine(); ////START Console.WriteLine("Welcome on KarlAI \n" + "1.|Hey Karl| followed by the instruction \n" + "\n\t Exemple : Hey Karl open google.com \n" + "\t\t : Hey Karl open spotify"); while (true) { RecognizeSpeechAsync(wakeup, bot).Wait(); //Code pour essayer Karl en mode console #region CodeConsole //string informations = Console.ReadLine(); //if (wakeup.Ecouter(informations)) //{ // string commandes = wakeup.AvoirCommandes(informations); // if (commandes == "") // { // commandes = wakeup.AffirmationPrecedente; // wakeup.AffirmationPrecedente = ""; // } // bot.GetMessage(commandes); // string resultat = bot.Identifier(); // bot.Executer(resultat , wakeup); //} //if (informations.ToLower() == "exit") // break; #endregion } }
public void MethodB() { Wakeup p = new Wakeup(); p.MethodA(string); }
public void MethodB() { Wakeup p = new Wakeup(); p.MethodA("Hello, World"); }
public void MethodB() { Wakeup p = new Wakeup(); p.MethodA("Dsa"); }
public void Wait(RCClosure closure, RCLong timeout, RCLong fibers) { // At some point I want this to work for multiple fibers, // but the current version will only wait on a single fiber. if (fibers.Count == 1) { Fiber fiber; lock (_botLock) { fiber = (Fiber)_bots[fibers[0]].GetModule(typeof(Fiber)); } RCValue result = null; lock (fiber._fiberLock) { if (fiber._fiberResults.Count == fiber._fibers.Count) { fiber._fiberResults.TryGetValue(0, out result); } } if (result == null) { lock (_botLock) { Queue <RCClosure> waiters; if (_botWaiters.TryGetValue(fibers[0], out waiters)) { waiters.Enqueue(closure); } else { waiters = new Queue <RCClosure> (); waiters.Enqueue(closure); _botWaiters.Add(fibers[0], waiters); } RCAsyncState state = new RCAsyncState(this, closure, fibers); Wakeup wakeup = new Wakeup(state, _reset); Timer timer = new Timer(wakeup.ContinueBot); timer.Change(timeout[0], Timeout.Infinite); } } else { SafeYieldFromWait(closure, result); } } else if (fibers.Count == 2) { RCValue result = null; Fiber fiber; lock (_botLock) { fiber = (Fiber)_bots[fibers[0]].GetModule(typeof(Fiber)); } lock (fiber._fiberLock) { if (!fiber._fiberResults.TryGetValue(fibers[1], out result)) { Queue <RCClosure> waiters; if (fiber._fiberWaiters.TryGetValue(fibers[1], out waiters)) { waiters.Enqueue(closure); } else { waiters = new Queue <RCClosure> (); waiters.Enqueue(closure); fiber._fiberWaiters.Add(fibers[1], waiters); } RCAsyncState state = new RCAsyncState(this, closure, fibers); Wakeup wakeup = new Wakeup(state, _reset); Timer timer = new Timer(wakeup.ContinueFiber); timer.Change(timeout[0], Timeout.Infinite); } } if (result != null) { SafeYieldFromWait(closure, result); } } else { throw new Exception(); } }