private void Awake()
        {
            if (_Instance != null)
            {
                Destroy(gameObject);
                return;
            }

            if (isDontDestroyOnLoad)
            {
                DontDestroyOnLoad(gameObject);
            }

            _Instance = this;

            _serviceLocator = new ServiceLocator();
            _serviceLocator.InitServices();

            _mediaManager = _serviceLocator.Get <IMediaManager>();

            _mediaManager.StartedListeningEvent  += StartedRecordEventHandler;
            _mediaManager.FinishedListeningEvent += FinishedRecordEventHandler;
            _mediaManager.ListeningFailedEvent   += RecordFailedEventHandler;
            _mediaManager.BeginTalkigEvent       += BeginTalkigEventHandler;
            _mediaManager.EndTalkigEvent         += EndTalkigEventHandler;
            _mediaManager.EndAudioPlayingEvent   += EndAudioPlayingEventHandler;
        }
Example #2
0
        public void Init()
        {
            _speechRepeater        = AdvancedSpeechRepeater.Instance;
            _voiceDetectionManager = _speechRepeater.ServiceLocator.Get <IVoiceDetectionManager>();

            _soundContainer = new SoundContainer();
            _soundContainer.Init(_speechRepeater.audioConfig, _speechRepeater.transform);

            CheckMicrophones();
        }
        private void OnDestroy()
        {
            if (_Instance == this)
            {
                _mediaManager.StartedListeningEvent  -= StartedRecordEventHandler;
                _mediaManager.FinishedListeningEvent -= FinishedRecordEventHandler;
                _mediaManager.ListeningFailedEvent   -= RecordFailedEventHandler;
                _mediaManager.BeginTalkigEvent       -= BeginTalkigEventHandler;
                _mediaManager.EndTalkigEvent         -= EndTalkigEventHandler;
                _mediaManager.EndAudioPlayingEvent   -= EndAudioPlayingEventHandler;

                _Instance = null;
                _serviceLocator.Dispose();
            }
        }
Example #4
0
        // Should be used Start function because AdvancedSpeechRepeater.Instance inited in Awake function!
        private void Start()
        {
            _speechRepeater = AdvancedSpeechRepeater.Instance;

            _statusImage = rootObject.transform.Find("Image_Status").GetComponent <Image>();

            _startListeningButton = rootObject.transform.Find("Button_StartListening").GetComponent <Button>();
            _stopListeningButton  = rootObject.transform.Find("Button_StopListening").GetComponent <Button>();

            _startListeningButton.onClick.AddListener(StartListeningButtonOnClickHandler);
            _stopListeningButton.onClick.AddListener(StopListeningButtonOnClickHandler);

            _speechRepeater.BeginTalkigEvent     += BeginTalkingEventHandler;
            _speechRepeater.EndTalkigEvent       += EndTalkingEventHandler;
            _speechRepeater.EndAudioPlayingEvent += EndAudioPlayingEventHandler;
        }