private void Update()
        {
            CheckForErrorOnCall(MicStream.MicSetGain(InputGain));

            if (Input.GetKeyDown(KeyCode.Q))
            {
                CheckForErrorOnCall(MicStream.MicStartStream(KeepAllData, false));
            }
            else if (Input.GetKeyDown(KeyCode.W))
            {
                CheckForErrorOnCall(MicStream.MicStopStream());
            }
            else if (Input.GetKeyDown(KeyCode.A))
            {
                CheckForErrorOnCall(MicStream.MicStartRecording(SaveFileName, false));
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                string outputPath = MicStream.MicStopRecording();
                Debug.Log("Saved microphone audio to " + outputPath);
                CheckForErrorOnCall(MicStream.MicStopStream());
            }

            gameObject.transform.localScale = new Vector3(minObjectScale + averageAmplitude, minObjectScale + averageAmplitude, minObjectScale + averageAmplitude);
        }
Example #2
0
    // Update is called once per frame
    void Update ()
	{
        if (Input.GetKeyDown(KeyCode.W))
        {
            samplingData.Clear();
            CheckForErrorOnCall(MicStream.MicStartStream(KeepAllData, false));
            CheckForErrorOnCall(MicStream.MicSetGain(InputGain));

            _isStart = true;
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
            _isStart = false;
            CheckForErrorOnCall(MicStream.MicStopStream());
            WriteAudioData();

        }
	}
Example #3
0
 /// <summary>
 ///  stops the recording.
 /// </summary>
 void StopRecording()
 {
     isRecording = false;
     if (useUnityMic)
     {
         Microphone.End(null);  //Stop the audio recording  
     }
     else
     {
         OutputPath = MicStream.MicStopRecording();
         Debug.Log("Saved audio recording to " + OutputPath + ", " + SaveFileName);
         CheckForErrorOnCall(MicStream.MicStopStream());
         //Debug.Log("Recorded " + audioBuffer.Length + " audio data entries.");
         //goAudioSource.clip = AudioClip.Create("Recording", audioBuffer.Length, _numChannels, AudioSettings.outputSampleRate, false);
         //goAudioSource.clip.SetData(audioBuffer, 0);
         CheckForErrorOnCall(MicStream.MicDestroy());
     }
     Debug.Log("Stopped audio recording.");
     WEKITSpeechManager.Instance.ContinueRecognizer();
     Debug.Log("Listening to voice commands again.");
     changeColor(currentColor);
 }