forked from cgvr/DeltaVR
logging for audio transcription, etc
This commit is contained in:
@@ -37,7 +37,7 @@ void Start()
|
|||||||
XROrigin playerOrigin = other.GetComponent<XROrigin>();
|
XROrigin playerOrigin = other.GetComponent<XROrigin>();
|
||||||
if (controller != null || playerOrigin != null)
|
if (controller != null || playerOrigin != null)
|
||||||
{
|
{
|
||||||
string inputPrompt = voiceTranscriptionTestBox.LastTextOutput;
|
string inputPrompt = voiceTranscriptionTestBox.GetTextOutput();
|
||||||
string refinedPrompt = inputPrompt + promptSuffix;
|
string refinedPrompt = inputPrompt + promptSuffix;
|
||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
|||||||
@@ -17,25 +17,22 @@ public class VoiceTranscriptionBox : MonoBehaviour
|
|||||||
|
|
||||||
private WhisperStream stream;
|
private WhisperStream stream;
|
||||||
|
|
||||||
private string lastTextOutput;
|
private string textOutput;
|
||||||
public string LastTextOutput
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return lastTextOutput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
async void Start()
|
async void Start()
|
||||||
{
|
{
|
||||||
meshRenderer = GetComponent<MeshRenderer>();
|
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
|
// This causes about 1 sec long freeze, has to be done once at the start of the game
|
||||||
microphoneRecord.StartRecord();
|
microphoneRecord.StartRecord();
|
||||||
|
|
||||||
stream = await whisper.CreateStream(microphoneRecord);
|
stream = await whisper.CreateStream(microphoneRecord);
|
||||||
stream.OnResultUpdated += OnWhisperResult;
|
stream.OnResultUpdated += OnWhisperResult;
|
||||||
|
Debug.Log("Microphone started and Whisper stream created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@@ -52,6 +49,7 @@ public class VoiceTranscriptionBox : MonoBehaviour
|
|||||||
{
|
{
|
||||||
meshRenderer.material = activeMaterial;
|
meshRenderer.material = activeMaterial;
|
||||||
stream.StartStream();
|
stream.StartStream();
|
||||||
|
Debug.Log("Whisper stream started.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +60,14 @@ public class VoiceTranscriptionBox : MonoBehaviour
|
|||||||
if (controller != null | playerOrigin != null)
|
if (controller != null | playerOrigin != null)
|
||||||
{
|
{
|
||||||
stream.StopStream();
|
stream.StopStream();
|
||||||
|
textOutput = outputText.text;
|
||||||
meshRenderer.material = inactiveMaterial;
|
meshRenderer.material = inactiveMaterial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWhisperResult(string result)
|
private void OnWhisperResult(string result)
|
||||||
{
|
{
|
||||||
lastTextOutput = result;
|
Debug.Log("Whisper result processed: " + result);
|
||||||
outputText.text = result;
|
outputText.text = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,4 +76,9 @@ public class VoiceTranscriptionBox : MonoBehaviour
|
|||||||
microphoneRecord.StopRecord();
|
microphoneRecord.StopRecord();
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetTextOutput()
|
||||||
|
{
|
||||||
|
return textOutput;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user