1
0
forked from cgvr/DeltaVR

logging for audio transcription, etc

This commit is contained in:
2025-12-31 15:26:07 +02:00
parent 0c8c55f293
commit 4fa73e5035
3 changed files with 16 additions and 12 deletions

View File

@@ -37,7 +37,7 @@ void Start()
XROrigin playerOrigin = other.GetComponent<XROrigin>();
if (controller != null || playerOrigin != null)
{
string inputPrompt = voiceTranscriptionTestBox.LastTextOutput;
string inputPrompt = voiceTranscriptionTestBox.GetTextOutput();
string refinedPrompt = inputPrompt + promptSuffix;
isLoading = true;

View File

@@ -17,25 +17,22 @@ public class VoiceTranscriptionBox : MonoBehaviour
private WhisperStream stream;
private string lastTextOutput;
public string LastTextOutput
{
get
{
return lastTextOutput;
}
}
private string textOutput;
// Start is called before the first frame update
async void Start()
{
meshRenderer = GetComponent<MeshRenderer>();
var micDevices = Microphone.devices;
Debug.Log("Mic devices: " + string.Join(", ", micDevices));
// 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;
Debug.Log("Microphone started and Whisper stream created.");
}
// Update is called once per frame
@@ -52,6 +49,7 @@ public class VoiceTranscriptionBox : MonoBehaviour
{
meshRenderer.material = activeMaterial;
stream.StartStream();
Debug.Log("Whisper stream started.");
}
}
@@ -62,13 +60,14 @@ public class VoiceTranscriptionBox : MonoBehaviour
if (controller != null | playerOrigin != null)
{
stream.StopStream();
textOutput = outputText.text;
meshRenderer.material = inactiveMaterial;
}
}
private void OnWhisperResult(string result)
{
lastTextOutput = result;
Debug.Log("Whisper result processed: " + result);
outputText.text = result;
}
@@ -77,4 +76,9 @@ public class VoiceTranscriptionBox : MonoBehaviour
microphoneRecord.StopRecord();
Destroy(gameObject);
}
public string GetTextOutput()
{
return textOutput;
}
}

Binary file not shown.