From 4fa73e50351ad3e6683fa6c4d2105612433fee0a Mon Sep 17 00:00:00 2001 From: henrisel Date: Wed, 31 Dec 2025 15:26:07 +0200 Subject: [PATCH] logging for audio transcription, etc --- .../ModeGeneration/ImageGenerationBox.cs | 2 +- .../ModeGeneration/VoiceTranscriptionBox.cs | 22 +++++++++++-------- ProjectSettings/AudioManager.asset | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ImageGenerationBox.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ImageGenerationBox.cs index 60829a09..39511832 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ImageGenerationBox.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ImageGenerationBox.cs @@ -37,7 +37,7 @@ void Start() XROrigin playerOrigin = other.GetComponent(); if (controller != null || playerOrigin != null) { - string inputPrompt = voiceTranscriptionTestBox.LastTextOutput; + string inputPrompt = voiceTranscriptionTestBox.GetTextOutput(); string refinedPrompt = inputPrompt + promptSuffix; isLoading = true; diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/VoiceTranscriptionBox.cs b/Assets/_PROJECT/Scripts/ModeGeneration/VoiceTranscriptionBox.cs index 4e6002b1..dcbfc652 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/VoiceTranscriptionBox.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/VoiceTranscriptionBox.cs @@ -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(); + 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; + } } diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset index bc6abbd7..061963e3 100644 --- a/ProjectSettings/AudioManager.asset +++ b/ProjectSettings/AudioManager.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7105b1e15f990334af69cbdcfaa594a4a4987ca2525675bc70e807344831d95d -size 446 +oid sha256:c360e8f38f20f70b2e82ee45d8bfaaa8f2e88decfc868628077ea60eea9fbd2f +size 463