示例#1
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 10, 80, 70), "Start"))
     {
         audio = Microphone.Start("Mic in at front panel (black) (Realtek High Definition Audio)", false, 10, 44100);
     }
     if (GUI.Button(new Rect(10, 90, 80, 70), "Stop"))
     {
         SavWav.Save(fileName, audio);
         UploadFile(m_URL);
         //        audio.Play();
     }
     if (GUI.Button(new Rect(10, 170, 80, 70), "Repeat"))
     {
         Speak.qs_no = Speak.qs_no - 1;
         Speak.startSpeaking();
     }
     if (LoadOut)
     {
         //GUI.skin = guiSkin;
         GUI.Box(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 30, 300, 60), LoadOutText);
     }
     GUI.contentColor = Color.black;
     GUI.Label(new Rect(100, 50, 1200, 200), ans);
 }
示例#2
0
    IEnumerator UploadFileCo(string uploadURL)
    {
        var filePath  = Path.Combine(Application.persistentDataPath, fileName);
        WWW localFile = new WWW("file:///" + filePath);

        Debug.Log(filePath);
        yield return(localFile);

        if (localFile.error == null)
        {
            Debug.Log("Loaded file successfully");
        }
        else
        {
            Debug.Log("Open file error: " + localFile.error);
            yield break; // stop the coroutine here
        }
        WWWForm postForm = new WWWForm();

        // version 1
        //postForm.AddBinaryData("theFile",localFile.bytes);
        // version 2
        LoadOut     = true;
        LoadOutText = "Processing your answer...";
        postForm.AddBinaryData("theFile", localFile.bytes, fileName, "text/plain");
        WWW upload = new WWW(uploadURL, postForm);

        yield return(upload);

        ans = upload.text;
        if (upload.error == null)
        {
            Debug.Log("Result= " + upload.text);
            LoadOut = false;
            Speak.startSpeaking();
        }
        else
        {
            Debug.Log("Error during upload: " + upload.error);
        }
    }