forked from cgvr/DeltaVR
cafe waiter npc and mic detect speech more
This commit is contained in:
@@ -50,9 +50,9 @@ public class CafeWaiterNPC : NPCController
|
||||
{
|
||||
SpeakVoiceLine(0);
|
||||
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
|
||||
notepad.SetActive(true);
|
||||
state = 1;
|
||||
@@ -76,7 +76,7 @@ public class CafeWaiterNPC : NPCController
|
||||
|
||||
private void OnPlayerSpeechFinished(string playerText)
|
||||
{
|
||||
if (Time.time < lastPlayerVoiceUpdateTime + 0.5f)
|
||||
if (Time.time < lastPlayerVoiceUpdateTime + 1.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -85,23 +85,34 @@ public class CafeWaiterNPC : NPCController
|
||||
if (state == 1)
|
||||
{
|
||||
// Show transcription and ask whether it is correct
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
notepadText.text = playerText;
|
||||
notepad.transform.DOLocalRotate(notepadFlippedRotation, 0.5f);
|
||||
notepad.transform.DOLocalRotate(notepadFlippedRotation, 0.5f).OnComplete(() =>
|
||||
{
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
});
|
||||
SpeakVoiceLine(1);
|
||||
state = 2;
|
||||
} else if (state == 2)
|
||||
{
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
// Flip notepad back
|
||||
notepad.transform.DOLocalRotate(notepadOriginalRotation, 0.5f);
|
||||
// if player answered positively, bring food, otherwise ask again
|
||||
if (playerText.ToLower().Contains("yes"))
|
||||
if (playerText.ToLower().Contains("ye"))
|
||||
{
|
||||
|
||||
SpeakVoiceLine(2);
|
||||
Invoke("BringFood", 1f);
|
||||
state = 3;
|
||||
} else
|
||||
{
|
||||
SpeakVoiceLine(3);
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
@@ -113,6 +124,14 @@ public class CafeWaiterNPC : NPCController
|
||||
if (state == 1)
|
||||
{
|
||||
notepadText.text = playerText;
|
||||
|
||||
// For now, when something is transcribed, treat it as player finished speaking
|
||||
OnPlayerSpeechFinished(playerText);
|
||||
}
|
||||
// faster reaction to player answering yes/no
|
||||
else if (state == 2)
|
||||
{
|
||||
OnPlayerSpeechFinished(playerText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user