// extra data 1: file path
        // extra data 2: device name
        // extra data 3: second device name
        public override void HotkeyTriggered()
        {
            if (audioDevice == null)
            {
                audioDevice = MainAudio.Instance.GetDevice(ExtraData2);
            }

            MainLogic.Instance.InputCallbacks.TextResultRequestOnTopCallback("Text",
                                                                             (bool speakCanceled, string speakInput) =>
            {
                if (!speakCanceled)
                {
                    try
                    {
                        string fileName = "tts_" + Guid.NewGuid() + ".wav";
                        if (speechSynthesizer == null)
                        {
                            speechSynthesizer = new SpeechSynthesizer();
                        }
                        speechSynthesizer.SetOutputToWaveFile(fileName);
                        speechSynthesizer.Speak(speakInput);
                        try
                        {
                            speechSynthesizer?.Dispose();
                        }
                        catch (Exception) { }
                        speechSynthesizer = null;
                        //var voices = speechSynthesizer.GetInstalledVoices();

                        files.Add(fileName);

                        CachedSound sound = new CachedSound(fileName);
                        provider          = audioDevice.AssociatedEngine.PlaySound(sound);

                        if (!String.IsNullOrWhiteSpace(ExtraData3))
                        {
                            if (audioDeviceTwo == null)
                            {
                                audioDeviceTwo = MainAudio.Instance.GetDevice(ExtraData3);
                            }

                            providerTwo = audioDeviceTwo.AssociatedEngine.PlaySound(sound);
                        }

                        if (AdditionalExtraData != null && AdditionalExtraData.ContainsKey((int)HotkeyAdditionalDataType.DeviceThree) && !String.IsNullOrWhiteSpace(AdditionalExtraData[(int)HotkeyAdditionalDataType.DeviceThree]))
                        {
                            if (audioDeviceThree == null)
                            {
                                audioDeviceThree = MainAudio.Instance.GetDevice(AdditionalExtraData[(int)HotkeyAdditionalDataType.DeviceThree]);
                            }

                            providerThree = audioDeviceThree.AssociatedEngine.PlaySound(sound);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            });
        }
        // extra data 1: file path
        // extra data 2: device name
        // extra data 3: second device name
        public override void HotkeyTriggered()
        {
            if (audioDevice == null)
            {
                audioDevice = MainAudio.Instance.GetDevice(ExtraData2);
            }

            provider = audioDevice.AssociatedEngine.PlaySound(cachedSound);

            if (!String.IsNullOrWhiteSpace(ExtraData3))
            {
                if (audioDeviceTwo == null)
                {
                    audioDeviceTwo = MainAudio.Instance.GetDevice(ExtraData3);
                }

                providerTwo = audioDeviceTwo.AssociatedEngine.PlaySound(cachedSound);
            }

            if (AdditionalExtraData != null && AdditionalExtraData.ContainsKey((int)HotkeyAdditionalDataType.DeviceThree) && !String.IsNullOrWhiteSpace(AdditionalExtraData[(int)HotkeyAdditionalDataType.DeviceThree]))
            {
                if (audioDeviceThree == null)
                {
                    audioDeviceThree = MainAudio.Instance.GetDevice(AdditionalExtraData[(int)HotkeyAdditionalDataType.DeviceThree]);
                }

                providerThree = audioDeviceThree.AssociatedEngine.PlaySound(cachedSound);
            }
        }
Beispiel #3
0
 public string GetAdditionalData(HotkeyAdditionalDataType additionalDataType)
 {
     if (AdditionalExtraData != null && AdditionalExtraData.ContainsKey((int)additionalDataType))
     {
         return(AdditionalExtraData[(int)additionalDataType]);
     }
     return(null);
 }
Beispiel #4
0
        public void SetAdditionalData(HotkeyAdditionalDataType additionalDataType, string value)
        {
            if (AdditionalExtraData == null)
            {
                AdditionalExtraData = new Dictionary <int, string>();
            }

            if (AdditionalExtraData.ContainsKey((int)additionalDataType))
            {
                AdditionalExtraData[(int)additionalDataType] = value;
            }
            else
            {
                AdditionalExtraData.Add((int)additionalDataType, value);
            }
        }