0x0001F36D 5 роки тому
батько
коміт
b569180592
1 змінених файлів з 17 додано та 4 видалено
  1. 17 4
      src/Yuuna.Contracts/Plugins/PluginGateway.cs

+ 17 - 4
src/Yuuna.Contracts/Plugins/PluginGateway.cs

@@ -19,13 +19,26 @@ namespace Yuuna.Contracts.Plugins
         {
             // Send("打開門");
             // Send("開燈");
+            try
+            {
 
-            var stt = SpeechRecognizer.Create("secret.json");
-            stt.RecognizeCompleted += a => Send(a[0].Transcript); 
-            using (stt.Recognize())
+                var stt = SpeechRecognizer.Create("secret.json");
+                stt.RecognizeCompleted += a =>
+                {
+                    Console.WriteLine("From Google Cloud Speech: "+a[0].Transcript);
+                    Send(a[0].Transcript);
+                };
+                using (stt.Recognize())
+                {
+                    Console.WriteLine("請說 [打開燈] 並按下 Enter 鍵");
+                    Console.ReadKey();
+                }
+            }
+            catch (Exception e)
             {
-                Console.ReadKey();
+                Console.WriteLine(e.Message);
             }
+            Console.ReadKey();
         }
 
         public static void Send(string text)