Powered by DocFX

Search Results for

    Setup Voice Activity Detector

    Editor

    1. Add Voice Activity Detector component to the scene, enable flag Auto Start and connect language model provider and speech source to it.

    2. Test voice activity detector.

      1. Create a script called VoiceActivityDetectorListener.cs.

        using UnityEngine;
        
        public class VoiceActivityDetectorListener : MonoBehaviour
        {
            public void OnSpoke()
            {
                Debug.Log("spoke");
            }
        
            public void OnSilenced()
            {
                Debug.Log("silenced");
            }
        }
        
      2. Add the Voice Activity Detector Listener script and connect it to the Voice Activity Detector events.

        Voice Activity Detector

      3. Press Play.

        Voice Activity Detector

    Scripting

    using Recognissimo.Components;
    using UnityEngine;
    
    public class SpeechSourceExample : MonoBehaviour
    {
        private void Awake()
        {
            // Create components.
            var vad = gameObject.AddComponent<VoiceActivityDetector>();
            var languageModelProvider = gameObject.AddComponent<StreamingAssetsLanguageModelProvider>();
            var speechSource = gameObject.AddComponent<MicrophoneSpeechSource>();
            
            // Setup speech source and language model provider as in the previous example.
            // ...
            
            // Bind speech processor dependencies.
            vad.LanguageModelProvider = languageModelProvider;
            vad.SpeechSource = speechSource;
    
            // Setup voice control
            vad.TimeoutMs = 200;
            
            vad.Spoke.AddListener(() => Debug.Log("Spoke"));
            vad.Silenced.AddListener(() => Debug.Log("Silenced"));
            
            vad.StartProcessing();
        }
    }