/// <summary> /// 停止录音 /// </summary> public void StopRecord() { totalRecordedTime = (float)(DateTime.Now - lastRecordStartTime).TotalSeconds; if (Microphone.IsRecording(null)) { Microphone.End(null); } SetLastRecordByteArray(); }
private void Update() { if (!Microphone.IsRecording(selectedDevice)) { source.Stop(); source.clip = Microphone.Start(selectedDevice, false, 10, maxSamplingFreq); source.Play(); } }
void StopRecord() { if (!Microphone.IsRecording(null)) { return; } Microphone.End(null); audio.Stop(); }
void OnGUI() { MicDeviceGUI((Screen.width / 2) - 150, (Screen.height / 2) - 75, 300, 100, 10, -300); if (Microphone.IsRecording(selectedDevice)) { ramFlushTimer += Time.fixedDeltaTime; RamFlush(); } }
private void RamFlush() { if (ramFlushTimer >= ramFlushSpeed && Microphone.IsRecording(selectedDevice)) { StopMicrophone(); StartMicrophone(); ramFlushTimer = 0; } }
private IEnumerator RecordingHandler() { Log.Debug("ExampleStreaming.RecordingHandler()", "devices: {0}", Microphone.devices); _recording = Microphone.Start(_microphoneID, true, _recordingBufferSize, _recordingHZ); yield return(null); // let _recordingRoutine get set.. if (_recording == null) { StopRecording(); yield break; } bool bFirstBlock = true; int midPoint = _recording.samples / 2; float[] samples = null; while (_recordingRoutine != 0 && _recording != null) { int writePos = Microphone.GetPosition(_microphoneID); if (writePos > _recording.samples || !Microphone.IsRecording(_microphoneID)) { Log.Error("ExampleStreaming.RecordingHandler()", "Microphone disconnected."); StopRecording(); yield break; } if ((bFirstBlock && writePos >= midPoint) || (!bFirstBlock && writePos < midPoint)) { // front block is recorded, make a RecordClip and pass it onto our callback. samples = new float[midPoint]; _recording.GetData(samples, bFirstBlock ? 0 : midPoint); AudioData record = new AudioData(); record.MaxLevel = Mathf.Max(Mathf.Abs(Mathf.Min(samples)), Mathf.Max(samples)); record.Clip = AudioClip.Create("Recording", midPoint, _recording.channels, _recordingHZ, false); record.Clip.SetData(samples, 0); _service.OnListen(record); bFirstBlock = !bFirstBlock; } else { // calculate the number of samples remaining until we ready for a block of audio, // and wait that amount of time it will take to record. int remaining = bFirstBlock ? (midPoint - writePos) : (_recording.samples - writePos); float timeRemaining = (float)remaining / (float)_recordingHZ; yield return(new WaitForSeconds(timeRemaining)); } } yield break; }
/// <summary> /// 结束录音 /// </summary> public void StopRecord() { if (Microphone.IsRecording(null)) { Microphone.End(null); audioSource.clip = clip; audioSource.Play(); } }
/** Used in Button "On Click" function */ public void RecordSound() { //Check if default microphone is recording if (Microphone.IsRecording("")) { return; } aud.clip = Microphone.Start("", false, recLen, maxFreq); }
void Update() { if (!Microphone.IsRecording(null) && isRecording) { AudioLib.Save("test.wav", audioClip); GetComponentInChildren <Text>().text = "Start recording"; isRecording = false; } }
public void disable() { active = false; source.Stop(); source.clip = null; Debug.Log("Disabled"); Microphone.End(Microphone.devices[0]); Debug.Log(Microphone.IsRecording(Microphone.devices[0])); }
void Update() { // 3.a: Add condition to check if dictationRecognizer.Status is Running if (hasRecordingStarted && !Microphone.IsRecording(deviceName) && dictationRecognizer.Status == SpeechSystemStatus.Running) { // Reset the flag now that we're cleaning up the UI. hasRecordingStarted = false; } }
private void LateUpdate() { if (IsListening && !Microphone.IsRecording(DeviceName) && dictationRecognizer.Status == SpeechSystemStatus.Running) { // If the microphone stops as a result of timing out, make sure to manually stop the dictation recognizer. StartCoroutine(StopRecording()); IsRecording = false; } }
private void OnClickPlayBtn() { if ((isHaveMicrophone == false) || (Microphone.IsRecording(devices[0]) || aud.clip == null)) { return; } //播放录音 aud.Play(); }
private void OnClickStartBtn() { if ((isHaveMicrophone == false) || (Microphone.IsRecording(devices[0]))) { return; } //开始录音 aud.clip = Microphone.Start(devices[0], true, 20, 44100); }
/// <summary> /// タップのホールドをキャンセルしたときの処理 /// </summary> /// <param name="eventData">ホールドのイベントデータ</param> public void OnHoldCanceled(HoldEventData eventData) { view.OnHoldCanceled(); if (Microphone.IsRecording(null)) { //録音中であれば録音停止 Microphone.End(null); } }
void Start() { Microphone.IsRecording(null); var j = Newtonsoft.Json.JsonConvert.DeserializeObject("{\"err\":\"0\"}") as JObject; StartCoroutine(OnRequestCamera()); new Thread(new ThreadStart(() => { })).Start(); new System.Threading.Tasks.Task(() => { }).Start(); }
/// <summary> /// ホールドのキャンセル /// </summary> /// <param name="eventData"></param> public void OnHoldCanceled(HoldEventData eventData) { // 録音の中断 _recordingEventEventSubject.OnNext(RecordingEvent.Cancel); if (Microphone.IsRecording(null)) { Microphone.End(null); } }
private void StopRecord() { if (!Microphone.IsRecording(null)) { return; } Microphone.End(null); myAudio.Stop(); Log(""); }
void Update() { // 添加条件来检查是否会识别。运行状态 if (hasRecordingStarted && !Microphone.IsRecording(deviceName) && dictationRecognizer.Status == SpeechSystemStatus.Running) { hasRecordingStarted = false; SendMessage("RecordStop"); } }
/// <summary> /// Tells the default device to start recording if it is not already. /// </summary> public void StartRecording() { if (!Microphone.IsRecording(null)) { m_ForcedStopRecording = false; m_RecordingStartTime = Time.time; m_RecordedAudio = Microphone.Start(null, false, m_MaxRecordingLengthInSeconds, m_RecordingFrequency); StartCoroutine(WaitForRecordingTimeout()); } }
public void StartChat() { if (Microphone.IsRecording(deviceName)) { return; } Debug.Log("开始录制"); recordClip = Microphone.Start(deviceName, false, MAX_LENGTH, SAMPLES_PER_SEC); curLength = 0f; }
public void StopCaptureVoice() { if (Microphone.IsRecording(null) == false) { return; } Microphone.End(null); m_AudioSource.Stop(); }
public override void Record() { base.Record(); if (!Recording && Microphone.IsRecording(null)) { int lastSample = Microphone.GetPosition(null); Microphone.End(null); //Stop the audio recording AudioSource.clip = TrimClip(_clip, lastSample); } }
/// <summary> /// 停止录音 /// </summary> public void StopRecordAudio() { ShowInfoLog("结束录音....."); if (!Microphone.IsRecording(null)) { return; } Microphone.End(null); CurAudioSource.Stop(); }
public void StopMicrophone() { #if !REK_MICROPHONE_DISABLED if (Microphone.IsRecording(DeviceName)) { Microphone.End(DeviceName); audioSource.Stop(); } #endif }
private void StartRecording() { if (micConnected && !Microphone.IsRecording(null)) { clip = Microphone.Start(null, true, 2, maxFreq); source.clip = clip; } Invoke("StopRecording", 2f); }
void Break() { if (Microphone.IsRecording(null)) { End(); } _started = true; newClip = Microphone.Start(null, false, 100, 44100); }
public bool IsRecording() { if (selectedDevice != null) { return(Microphone.IsRecording(selectedDevice)); } Debug.LogError("<b>[SoundStone]</b> No Audio Source Found!"); return(false); }
public void StartRecordHello() { if (!Microphone.IsRecording(null)) { recoHello = Microphone.Start(null, false, 15, 44100); isRecord = true; index = 4; } GameObject.Find("Canvas").GetComponent <Speaker>().AddMessHello(recoHello); }
public void Play() { if (!Microphone.IsRecording("")) { if (audioSource.clip != null) { audioSource.Play(); } } }