cancel
Showing results for 
Search instead for 
Did you mean: 

Voice SDK Dictation FullTranscription Event

BruceBravehart
Honored Guest

Hey I am working on a Project, where I want to use the Dictation function from the Voice SDK. I managed to get it running, except for returning the transcription. The Console Log shows, that Wit.ai managed to transcribe my voice input, but I can't figure out how to do the Event Listener to retrieve the output. 

The documentation offers little insight. The API reference  shows an Event, which could be used, but it can't be registered. 

I am using unity 6000.0.42f1 and meta all-in-one sdk v74

Here is the code i use:

using UnityEngine;
using UnityEngine.Events;
using Oculus.Voice.Dictation;
using Meta.WitAi.Dictation;
using Meta.WitAi.CallbackHandlers;



public class GameManager : MonoBehaviour
{


    [SerializeField] private AppDictationExperience dictationService;
    private void Start()
    {

        if (dictationService != null)
        {          
            dictationService.OnFullTranscription += OnFullTranscription;
            //does not work

            Debug.Log("DictationService component found!");

            foreach (var field in typeof(AppDictationExperience).GetFields())
            {
                if (field.FieldType == typeof(UnityEvent))
                {
                    UnityEvent unityEvent = (UnityEvent)field.GetValue(dictationService);
                    Debug.Log(field.Name + " has " + unityEvent.GetPersistentEventCount() + " listeners.");
                }
            }
        }
        else
        {
            Debug.LogError("DictationService component not found on the found GameObject!");
        }



    }


    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Space key pressed!");
            // Start listening for voice input
            dictationService.ActivateImmediately();
        }
        else if (Input.GetKeyUp(KeyCode.Space))
        {
            Debug.Log("Space key released!");
            // Stop listening for voice input
            dictationService.Deactivate();
        }
    }


    private void OnFullTranscription(string command) // does not work
    {
        Debug.Log("Final transcription: " + command);
    }

    void OnDestroy()
    {
        dictationService.OnFullTranscription -= OnFullTranscription;
    }
}


 

0 REPLIES 0