1
0
forked from cgvr/DeltaVR

improve text recognition reliability, unsubscribe from Whisper events when not wanted anymore

This commit is contained in:
2026-01-28 16:14:27 +02:00
parent e0d68454c7
commit 876306a2af
4 changed files with 37 additions and 9 deletions

View File

@@ -24,8 +24,6 @@ public class CafeWaiterNPC : NPCController
private void Start()
{
fmodWhisperBridge.OnWhisperResultProcessed += ProcessPlayerSpeech;
notepadOriginalRotation = notepadTransform.localRotation.eulerAngles;
notepadFlippedRotation = notepadOriginalRotation + new Vector3(0, 180, 0);
}
@@ -33,12 +31,17 @@ public class CafeWaiterNPC : NPCController
protected override void OnPlayerApproach()
{
AudioManager.Instance.PlayDialogue(voiceLineKeys[0], gameObject);
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdate;
fmodWhisperBridge.OnWhisperSegmentFinished += ProcessPlayerSpeech;
fmodWhisperBridge.ActivateRecording();
}
protected override void OnPlayerLeave()
{
//AudioManager.Instance.PlayDialogue(voiceLineKeys[1], gameObject);
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdate;
fmodWhisperBridge.OnWhisperSegmentFinished -= ProcessPlayerSpeech;
fmodWhisperBridge.DeactivateRecording();
}
@@ -67,4 +70,13 @@ public class CafeWaiterNPC : NPCController
}
}
}
private void OnPlayerSpeechUpdate(string playerText)
{
if (string.IsNullOrEmpty(playerText) || playerText.Equals("BLANK_AUDIO"))
{
return;
}
notepadText.text = playerText;
}
}