|
|
@@ -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)
|