public CardEditorWindow(Settings settings, string tempDirPath, YandexSpeech yandexSpeech, Card card, bool withoutSpace)
        {
            InitializeComponent();

            Caption   = card.Title;
            Image     = SetImageFromPath(card.ImagePath);
            AudioPath = card.AudioPath;

            _yandexSpeech            = yandexSpeech;
            _tempDirPath             = tempDirPath;
            _settings                = settings;
            voiceSelect.ItemsSource  = YandexVoice.VOICES;
            voiceSelect.SelectedItem = YandexVoice.FindById(settings.VoiceId);
            acceptButton.Content     = "Изменить";

            _withoutSpace = withoutSpace;

            if (withoutSpace == true)
            {
                panelWithAudioButtons.Visibility   = Visibility.Hidden;
                infoAboutAudioTextBlock.Visibility = Visibility.Visible;
            }

            SetCardType(card.CardType);
        }
Example #2
0
        public SettingsWindow(Settings settings)
        {
            InitializeComponent();

            _settings = settings.Clone() as Settings;

            InitActions();

            _joysticks = new Joysticks();
            _joysticks.JoystickButtonDown += Joystick_JoystickButtonDown;

            isHazGazeEnabledCheckBox.IsChecked       = _settings.IsHasGazeEnabled;
            isAnimatedClickEnabledCheckBox.IsChecked = _settings.IsAnimatedClickEnabled;
            isPlayAudioFromCardCheckBox.IsChecked    = _settings.IsPlayAudioFromCard;
            isPageButtonVisibleCheckBox.IsChecked    = _settings.IsPageButtonVisible;

            isJoystickEnabledCheckBox.IsChecked = _settings.IsJoystickEnabled;
            isKeyboardEnabledCheckBox.IsChecked = _settings.IsKeyboardEnabled;
            isMouseEnabledCheckBox.IsChecked    = _settings.IsMouseEnabled;
            isOutputTypeCheckBox.IsChecked      = _settings.IsOutputType;

            voiceSelect.ItemsSource   = YandexVoice.VOICES;
            voiceSelect.SelectedIndex = YandexVoice.FindIndexById(_settings.VoiceId);

            DataContext = _settings;
        }
Example #3
0
        public async Task <string> GetAudio(string text, YandexVoice voice)
        {
            var client = new HttpClient();
//            client.Timeout = TimeSpan.FromMilliseconds(10000);
            var values = new Dictionary <string, string>
            {
                { "text", text },
                { "voice", voice.Id }
            };
            var content  = new FormUrlEncodedContent(values);
            var response = await client.PostAsync("http://linka.su:5443/voice", content);

            if (response.IsSuccessStatusCode == true)
            {
                var responseBytes = await response.Content.ReadAsByteArrayAsync();

                var audioFile = string.Format(@"{0}\{1}.mp3", _tempPath, System.Guid.NewGuid());
                File.WriteAllBytes(audioFile, responseBytes);

                return(audioFile);
            }

            return(null);
        }
Example #4
0
 public async Task <string> GetAudio(string text)
 {
     return(await GetAudio(text, YandexVoice.FindById(_settings.VoiceId)));
 }