1
0
forked from cgvr/DeltaVR

microphone recording working with FMOD!!!

This commit is contained in:
2026-01-14 18:02:41 +02:00
parent 96839e0e82
commit cb4d4036e7
12 changed files with 410 additions and 140 deletions

View File

@@ -1,36 +1,19 @@
using TMPro;
using UnityEngine;
using Whisper;
using Whisper.Utils;
public class MicrophoneStand : MonoBehaviour
{
public WhisperManager whisper;
public MicrophoneRecord microphoneRecord;
public string microphoneDevice;
public TextMeshProUGUI outputText;
private WhisperStream stream;
[SerializeField]
private string textOutput;
public GameObject microphoneOffStatus;
public GameObject microphoneOnStatus;
public FMODWhisperBridge fmodWhisperBridge;
// Start is called before the first frame update
async void Start()
void Start()
{
Debug.Log("Mic devices: " + string.Join(", ", Microphone.devices));
Debug.Log("Using mic device: " + microphoneDevice);
microphoneRecord.SelectedMicDevice = microphoneDevice;
// This causes about 1 sec long freeze, has to be done once at the start of the game
microphoneRecord.StartRecord();
stream = await whisper.CreateStream(microphoneRecord);
stream.OnResultUpdated += OnWhisperResult;
//stream.StartStream();
fmodWhisperBridge.OnWhisperResultProcessed += OnWhisperResult;
microphoneOffStatus.SetActive(true);
microphoneOnStatus.SetActive(false);
@@ -51,10 +34,7 @@ public class MicrophoneStand : MonoBehaviour
{
microphoneOffStatus.SetActive(false);
microphoneOnStatus.SetActive(true);
stream.StartStream();
//microphoneRecord.StartRecord();
Debug.Log("Whisper stream started.");
fmodWhisperBridge.ActivateRecording();
}
}
@@ -65,27 +45,17 @@ public class MicrophoneStand : MonoBehaviour
{
microphoneOffStatus.SetActive(true);
microphoneOnStatus.SetActive(false);
stream.StopStream();
//microphoneRecord.StopRecord();
textOutput = outputText.text;
fmodWhisperBridge.DeactivateRecording();
}
}
private void OnWhisperResult(string result)
{
Debug.Log("Whisper result processed: " + result);
outputText.text = result;
}
private void OnDestroy()
{
microphoneRecord.StopRecord();
Destroy(gameObject);
}
public string GetTextOutput()
{
return textOutput;
return outputText.text;
}
}