Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.Windows.Speech;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine.SceneManagement;
- using System.Diagnostics;
- public class Recognition : MonoBehaviour
- {
- KeywordRecognizer keywordRecognizer;
- Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
- private static Recognition instance;
- [SerializeField]
- [Header("Call Support keyword")]
- string supportKeyWord;
- [SerializeField]
- [Header("Call Remote Access keyword")]
- string RemoteAccess;
- [SerializeField]
- [Header("Call shutdown keyword")]
- string shutDownKeyword;
- [SerializeField]
- [Header("Call Statiscs keyword")]
- string dataKeyword;
- [SerializeField]
- [Header("Call Back to main menu keyword")]
- string mainMenuKeyword;
- private void Start()
- {
- DontDestroyOnLoad(this.gameObject);
- #region Singleton
- if (instance == null)
- instance = this;
- else
- {
- Destroy(this.gameObject);
- return;
- }
- #endregion
- keywords.Add(supportKeyWord, () =>
- {
- GoCalled();
- });
- keywords.Add(RemoteAccess, () =>
- {
- GoCalled2();
- });
- keywords.Add(shutDownKeyword, () =>
- {
- GoCalled3();
- });
- keywords.Add(dataKeyword, () =>
- {
- GoCalled4();
- });
- keywords.Add(mainMenuKeyword, () =>
- {
- GoCalled5();
- });
- keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
- keywordRecognizer.OnPhraseRecognized += KeyWordRecognizerOnPhraseRecognized;
- keywordRecognizer.Start();
- }
- void KeyWordRecognizerOnPhraseRecognized(PhraseRecognizedEventArgs args)
- {
- System.Action keywordAction;
- if (keywords.TryGetValue(args.text, out keywordAction))
- {
- keywordAction.Invoke();
- }
- }
- void GoCalled()
- {
- print("Suporte Γ© minha rola dura");
- }
- void GoCalled2()
- {
- print("Acesso remoto");
- string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "TeamViewer");
- System.Diagnostics.Process.Start(filePath);
- //Application.OpenURL((Application.dataPath) + "file:///C:/Program%20Files%20(x86)/TeamViewer/CopyRights.txt");
- //Process p = new Process();
- //p.StartInfo.FileName = "file:///C:/Program%20Files%20(x86)/TeamViewer/TeamViewer.exe";
- //Process.Start("Mozilla.exe", "https://rilix.herokuapp.com/login");
- //Application.OpenURL((Application.dataPath) + @"C:\Program Files (x86)\TeamViewer\TeamViewer.exe");
- //System.Diagnostics.Process.Start("TeamViewer.exe");
- //System.Diagnostics.Process.Start(Application.dataPath + "file:///C:/Program%20Files%20(x86)/TeamViewer/TeamViewer.exe");
- }
- void GoCalled3()
- {
- print("Sai fora, DESLIGUEI MERMΓO");
- }
- void GoCalled4()
- {
- print("Estatisticas");
- SceneManager.LoadScene("demo");
- }
- void GoCalled5()
- {
- print("Back to main");
- SceneManager.LoadScene("Main");
- }
- }
Add Comment
Please, Sign In to add comment