1
0
forked from cgvr/DeltaVR

radio transmitter keeps transmitting until text processing is completed

This commit is contained in:
2026-03-05 12:52:29 +02:00
parent 22f6982c4c
commit 33b86e09ae
3 changed files with 33 additions and 14 deletions

View File

@@ -14,11 +14,14 @@ public class RadioTransmitter : XRGrabInteractable
public ReleasableButton radioButton;
public TextMeshProUGUI computerScreen;
private bool isProcessing;
// Start is called before the first frame update
void Start()
{
radioButton.OnButtonPressed += OnRadioButtonPressed;
radioButton.OnButtonReleased += OnRadioButtonReleased;
isProcessing = false;
}
// Update is called once per frame
@@ -35,28 +38,35 @@ public class RadioTransmitter : XRGrabInteractable
private void OnRadioButtonPressed()
{
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
fmodWhisperBridge.ActivateRecording();
if (!isProcessing)
{
isProcessing = true;
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
fmodWhisperBridge.ActivateRecording();
}
}
private void OnRadioButtonReleased()
{
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
fmodWhisperBridge.DeactivateRecording();
}
private void OnPlayerSpeechUpdated(string text)
{
computerScreen.text = text;
OnPlayerFinishedSpeaking?.Invoke();
//OnPlayerFinishedSpeaking?.Invoke();
}
private void OnPlayerSpeechFinished(string playerText)
{
computerScreen.text = playerText;
isProcessing = false;
OnPlayerFinishedSpeaking?.Invoke();
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
fmodWhisperBridge.DeactivateRecording();
}
}