示例#1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("space key pushed");
            writer = new WAVWriter("Assets/WAV/result.wav", 1, 16000);
            clip   = Microphone.Start(Microphone.devices[0], true, lengthSeconds, samplingFrequency);
        }

        var position = Microphone.GetPosition(null);

        if (position < 0 || head == position)
        {
            return;
        }

        clip.GetData(microphoneBuffer, 0);
        while (GetDataLength(microphoneBuffer.Length, head, position) > processBuffer.Length)
        {
            var remain = microphoneBuffer.Length - head;
            if (remain < processBuffer.Length)
            {
                Array.Copy(microphoneBuffer, head, processBuffer, 0, remain);
                Array.Copy(microphoneBuffer, 0, processBuffer, remain, processBuffer.Length - remain);
            }
            else
            {
                Array.Copy(microphoneBuffer, head, processBuffer, 0, processBuffer.Length);
            }

            // processBufferを何か処理する部分。今回は.wavへ書き出し
            writer.Write(processBuffer);

            head += processBuffer.Length;
            if (head > microphoneBuffer.Length)
            {
                head -= microphoneBuffer.Length;
            }
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            Debug.Log("space key pushed2");
            writer.Close();
            cspy = GetComponent <CsPy>();
            //cspy.Python();
            enabled = false;
            //SshConect.connect = true;
            //SceneManager.LoadScene("SI3_women");
            //でばっぐ時ここコメントアウト
            SceneManager.LoadScene("loading");
        }
    }
 void Start()
 {
     Debug.Log("test");
     cs = GetComponent <CsPy>();
     cs.Python(pyCodePath);
 }