Beispiel #1
0
    public static void check()                                          //检查新版本和网络连接
    {
        WWW web = new WWW("http://central.holoworld.win/Version.html"); //检测版本号的地址

        if (web.error != null)
        {
            ShowMessage(Language.lang.notconnecttoserver);
        }
        while (!web.isDone)
        {
            System.Threading.Thread.Sleep(10);
        }
        string result = web.text;

        Debug.Log("check version: " + result.Contains(version));
        if (result.Contains(version))
        {
            SoundsControl.playText(Language.lang.welcome);
            if (GetString("id") == "-1")
            {
                ShowMessage(Language.lang.needlogin);
            }
        }
        else
        {
            SoundsControl.playText(Language.lang.needup);
            ShowMessage(Language.lang.newvirsonavaliavle);
        }
    }
Beispiel #2
0
 public static void startLogin()
 {
     Debug.Log("Start listen vocal print");
     StartRecording();
     SoundsControl.playAudio(ControlCenter.MainCamera.GetComponent <PrefebCollector>().logprocess);
     logining = true;
 }
 void Awake()
 {
     if (instance != null && instance != this) {
         Destroy(this.gameObject);
         return;
     } else {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Beispiel #4
0
    public static GameObject ShowMessage(string msg)
    {
        SoundsControl.playAudio(MainCamera.GetComponent <PrefebCollector>().msg);
        GameObject obj = Instantiate(Msg);

        obj.name = "msg_clone";
        obj.transform.position = new Vector3(facePosition.x, facePosition.y - 0.2f, facePosition.z);
        obj.transform.rotation = faceRotation;
        obj.transform.Find("Text").GetComponent <Text>().text = msg;
        obj.SetActive(true);
        Menu.SetActive(false);
        return(obj);
    }
        private void SearchNextName(object sender, EventArgs e)
        {
            bool res = SoundsControl.SearchName(textBoxSoundName.Text, true);

            if (res)
            {
                return;
            }

            DialogResult result = MessageBox.Show("No sound found", "Result", MessageBoxButtons.OKCancel,
                                                  MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);

            if (result == DialogResult.Cancel)
            {
                Close();
            }
        }
        private void Search_Id(object sender, EventArgs e)
        {
            if (!Utils.ConvertStringToInt(textBoxId.Text, out int graphic, 0, 0xFFF))
            {
                return;
            }

            bool res = SoundsControl.SearchId(graphic);

            if (res)
            {
                return;
            }

            DialogResult result = MessageBox.Show("No sound found", "Result", MessageBoxButtons.OKCancel,
                                                  MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);

            if (result == DialogResult.Cancel)
            {
                Close();
            }
        }
Beispiel #7
0
 private bool log(string[] entities)
 {
     try
     {
         foreach (string now in entities)
         {
             if (now.Contains("out") || now.Contains("unsign"))
             {
                 ControlCenter.SetString("id", "-1");
                 Login.logining = false;
                 SoundsControl.playAudio(ControlCenter.MainCamera.GetComponent <PrefebCollector>().msg);
                 return(true);
             }
             else if (now.Contains("in") || now.Contains("sign") || now.Contains("log"))
             {
                 Login.startLogin();
                 return(true);
             }
         }
     }
     catch { return(false); }
     return(false);
 }
Beispiel #8
0
 public static void startListen()
 {
     SoundsControl.playAudio(MainCamera.GetComponent <PrefebCollector>().vocalstart);
     VocalListener.StartRecording();
 }
Beispiel #9
0
 public void read()
 {
     SoundsControl.playText(info);
 }
Beispiel #10
0
 private void Awake()
 {
     instance = this;
 }
Beispiel #11
0
    // Update is called once per frame
    void Update()
    {
        if (Login.logining)
        {
            return;
        }
        if (resultAu != null && resultAu != "")
        {
            Debug.Log(resultAu);//输出最终结果
            if (resultAu.Contains("Error"))
            {
                ControlCenter.ShowMessage(Language.lang.error);
            }
            string operate = resultAu;
            resultAu = null;
            ControlCenter.MainCamera.GetComponent <LanguageUnderstand>().go(operate);
        }

        if (backgrountVolume == 0 && !Microphone.IsRecording(null))
        {
            Start();
        }
        else if (backgrountVolume == 0 && Microphone.IsRecording(null))
        {
            float length2 = Microphone.GetPosition(null) / samplingRate;
            if (length2 >= 2)
            {
                AudioClip outClip   = new AudioClip();
                int       outlength = 0;
                float[]   source2   = new float[Microphone.GetPosition(null) * clip.channels];
                EndRecording(out outlength, out outClip);
                clip.GetData(source2, 0);
                Array.Copy(source2, source2.Length - 16000, source2, 0, 16000);
                foreach (float now in source2)
                {
                    backgrountVolume += Mathf.Abs(now);
                }
                backgrountVolume /= source2.Length;
                maxRecordTime     = 10;
            }
            return;
        }
        if (!Microphone.IsRecording(null))
        {
            return;
        }

        float length = Microphone.GetPosition(null) / samplingRate;

        if (length >= 2)
        {
            float[] sourceI = new float[Microphone.GetPosition(null) * clip.channels];
            float[] source  = new float[24000];
            clip.GetData(sourceI, 0);
            Array.Copy(sourceI, sourceI.Length - 24000, source, 0, 24000);
            average = 0f;
            foreach (float now in source)
            {
                average += Mathf.Abs(now);
            }
            average /= source.Length;
            if ((Microphone.IsRecording(null) && !(average > backgrountVolume * 1.2f) && length > 1.5f) || length > 9.9f)
            {
                AudioClip outClip   = new AudioClip();
                int       outlength = 0;
                EndRecording(out outlength, out outClip);
                if (length > 2.1f)
                {
                    Debug.Log("Start get text");
                    LanguageUnderstand.ListenIcon = ListenIcon;
                    SoundsControl.playAudio(ControlCenter.MainCamera.GetComponent <PrefebCollector>().vocalend);
                    StartCoroutine(GetTextFromAudio(getWAV(outClip)));
                    resultAu = "";
                    //Debug.Log(GetTextFromAudio(getWAV(outClip)));
                }
                else
                {
                    ListenIcon.SetActive(false);
                }
            }
        }
    }
Beispiel #12
0
 // Update is called once per frame
 void Update()
 {
     if (logining && Microphone.IsRecording(null))
     {
         float length = Microphone.GetPosition(null) / samplingRate;
         if (length >= 2)
         {
             double  average = 0.0;
             float[] sourceI = new float[Microphone.GetPosition(null) * clip.channels];
             float[] source  = new float[24000];
             clip.GetData(sourceI, 0);
             Array.Copy(sourceI, sourceI.Length - 24000, source, 0, 24000);
             average = 0f;
             foreach (float now in source)
             {
                 average += Mathf.Abs(now);
             }
             average /= source.Length;
             if ((Microphone.IsRecording(null) && !(average > VocalListener.backgrountVolume * 1.2f) && length > 1.5f) || length > 9.9f)
             {
                 AudioClip outClip   = new AudioClip();
                 int       outlength = 0;
                 EndRecording(out outlength, out outClip);
                 if (length > 2.1f)
                 {
                     Debug.Log("Start post to login");
                     //ListenIcon.SetActive(false);
                     SoundsControl.playAudio(ControlCenter.MainCamera.GetComponent <PrefebCollector>().vocalend);
                     byte[] data = getWAV(outClip);
                     StartCoroutine(login(data));
                 }
                 else
                 {
                     ListenIcon.SetActive(false);
                     SoundsControl.playAudio(ControlCenter.MainCamera.GetComponent <PrefebCollector>().vocalend);
                     ControlCenter.ShowMessage(Language.lang.loginfail);
                 }
             }
         }
     }
     if (!string.IsNullOrEmpty(result))
     {
         Debug.Log(result);
         try
         {
             if (int.Parse(result) > 0)
             {
                 ControlCenter.SetString("id", result);
                 result = null;
                 SoundsControl.playAudio(ControlCenter.MainCamera.GetComponent <PrefebCollector>().logfinish);
             }
             else
             {
                 ControlCenter.ShowMessage(Language.lang.loginfail);
                 result = null;
             }
         }
         catch
         {
             ControlCenter.ShowMessage(Language.lang.loginfail);
             result = null;
         }
     }
 }