Ejemplo n.º 1
0
        public void Enqueue(TTSMessage message)
        {
            if (null == _parentTTS)
            {
                throw new InvalidOperationException("No associated Text-To-Speech subsystem for injection");
            }
            else if (message.AlreadySpoken())
            {
                throw new InvalidOperationException($"{GetType().Name}: message has already been spoken");
            }

            _parentTTS.TTSInitialize();

            uint messageKey;

            message.Voice = _parentTTS.CurrentVoice;
            vx_tts_status status = VivoxCoreInstance.vx_tts_speak(_parentTTS.TTSManagerId, message.Voice.Key, message.Text, (vx_tts_destination)message.Destination, out messageKey);

            if (TextToSpeech.IsNotTTSError(status))
            {
                message.Key              = messageKey;
                message.TTS              = _parentTTS;
                message.State            = TTSMessageState.Enqueued;
                message.PropertyChanged += OnMessage_PropertyChanged;
                _messages.Add(message);
                AfterMessageAdded?.Invoke(this, new ITTSMessageQueueEventArgs(message));
            }
            else
            {
                throw new VivoxApiException((int)status);
            }
        }