Ejemplo n.º 1
0
        private static List <SpeechFragment> Parse(SpeechSettings settings, IReadOnlyList <TextUnit> units)
        {
            var opsUntilNextRollEvent = 0f;
            var frags     = new List <SpeechFragment>();
            var cfg_stack = new Stack <SpeechSettings>();

            cfg_stack.Push(settings);
            var tag_stack   = new Stack <SpeechFragment.TagOpen>();
            var tmp_tag_pop = new Stack <SpeechFragment.TagOpen>();

            for (int ii = 0; ii < units.Count; ++ii)
            {
                var cfg  = cfg_stack.Peek();
                var unit = units[ii];
                if (unit is TextUnit.String s)
                {
                    for (int ic = 0; ic < s.fragment.Length; ++ic)
                    {
                        if ((opsUntilNextRollEvent -= cfg.opsPerChar(s.fragment, ic)) <= 0 &&
                            cfg.rollEventAllowed(s.fragment, ic) && cfg.rollEvent != null)
                        {
                            frags.Add(new SpeechFragment.RollEvent(cfg.rollEvent));
                            opsUntilNextRollEvent = cfg.opsPerRollEvent;
                        }
                        frags.Add(new SpeechFragment.Char(s.fragment[ic]));
                        var waitTime = cfg.opsPerChar(s.fragment, ic) / cfg.opsPerSecond;
                        if (waitTime > 0)
                        {
                            frags.Add(new SpeechFragment.Wait(waitTime));
                        }
                    }
                }
                else if (unit is TextUnit.OpenTag ot)
                {
                    var t = new SpeechFragment.TagOpen(ot.name, ToTag(ot.name, ot.content));
                    frags.Add(t);
                    tag_stack.Push(t);
                    cfg_stack.Push(t.tag.ModifySettings(cfg));
                }
                else if (unit is TextUnit.CloseTag ct)
                {
                    //Undo tags until the matching opening tag is found
                    while (tag_stack.TryPeek()?.name != ct.name)
                    {
                        if (tag_stack.Count == 0)
                        {
                            throw new Exception($"Could not find a matching opening tag for {ct.name}");
                        }
                        tmp_tag_pop.Push(tag_stack.Pop());
                        cfg_stack.Pop();
                    }
                    frags.Add(new SpeechFragment.TagClose(tag_stack.Pop()));
                    cfg_stack.Pop();
                    //Reapply tags that were popped
                    while (tmp_tag_pop.Count > 0)
                    {
                        var t = tmp_tag_pop.Pop();
                        tag_stack.Push(t);
                        cfg_stack.Push(t.tag.ModifySettings(cfg_stack.Peek()));
                    }
                }
            }
            return(frags);
        }
Ejemplo n.º 2
0
 public Speech(string raw, SpeechSettings?cfg = null)
 {
     this.raw = raw;
     this.cfg = cfg ?? SpeechSettings.Default;
 }
Ejemplo n.º 3
0
        public void Return_True_When_Input_Is_Valid(SpeechSettings settings)
        {
            ValidationResult result = validator.Validate(settings);

            Assert.True(result.IsValid);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NvdaDriverOptions"/> class.
        /// </summary>
        public NvdaDriverOptions()
        {
            GeneralSettings = new GeneralSettings
            {
                Language = NvdaLanguage.English,
                PlayStartAndExitSounds = true,
            };

            SpeechSettings = new SpeechSettings
            {
                AutoDialectSwitching       = false,
                AutoLanguageSwitching      = true,
                IncludeUnicodeDescriptions = true,
                PunctuationLevel           = PunctuationLevel.Some,
                SayCapForCapitals          = false,
                UseSpellingFunctionality   = true,
            };

            DocumentFormattingSettings = new DocumentFormattingSettings
            {
                ReportFontName             = false,
                ReportFontSize             = false,
                ReportFontAttributes       = false,
                ReportEmphasis             = false,
                ReportStyle                = false,
                ReportColor                = false,
                ReportComments             = true,
                ReportRevisions            = true,
                ReportSpellingErrors       = true,
                ReportPage                 = true,
                ReportLineNumber           = false,
                ReportLineIndentation      = false,
                ReportParagraphIndentation = false,
                ReportLineSpacing          = false,
                ReportAlignment            = false,
                ReportTables               = true,
                ReportTableHeaders         = true,
                ReportTableCellCoords      = true,
                ReportBorderColor          = false,
                ReportBorderStyle          = false,
                ReportHeadings             = true,
                ReportLinks                = true,
                ReportLists                = true,
                ReportBlockQuotes          = true,
                ReportLandmarks            = true,
                ReportFrames               = true,
                ReportClickable            = true,
                DetectFormatAfterCursor    = false,
                IncludeLayoutTables        = false,
            };

            InputCompositionSettings = new InputCompositionSettings
            {
                AutoReportAllCandidates   = true,
                AnnounceSelectedCandidate = true,
                AlwaysIncludeShortCharacterDescriptionInCandidateName = true,
                ReportReadingStringChanges     = true,
                ReportCompositionStringChanges = true,
            };

            KeyboardSettings = new KeyboardSettings
            {
                KeyboardLayout          = KeyboardLayout.Desktop,
                SpeakTypedCharacters    = true,
                SpeakTypedWords         = false,
                SpeechInterruptForEnter = true,
            };

            PresentationSettings = new PresentationSettings
            {
                ReportTooltips                  = false,
                ReportHelpBalloons              = true,
                ReportKeyboardShortcuts         = true,
                ReportObjectPositionInformation = true,
                GuessObjectPositionInformationWhenUnavailable = false,
                ReportObjectDescriptions = true,
                ProgressBarUpdates       = new ProgressBarUpdateSettings
                {
                    ProgressBarOutputMode        = ProgressBarOutputMode.Beep,
                    ReportBackgroundProgressBars = false,
                },
                ReportDynamicContentChanges = true,
            };

            ReviewCursorSettings = new ReviewCursorSettings
            {
                FollowFocus      = true,
                FollowCaret      = true,
                FollowMouse      = false,
                SimpleReviewMode = true,
            };

            BrowseModeSettings = new BrowseModesSettings
            {
                MaxLineLength                = 100,
                LinesPerPage                 = 25,
                UseScreenLayout              = true,
                AutoSayAllOnPageLoad         = true,
                AutoPassThroughOnCaretMove   = false,
                AutoPassThroughOnFocusChange = true,
                TrapNonCommandGestures       = true,
            };
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Apply modifications to the text unrolling settings.
 /// </summary>
 public virtual SpeechSettings ModifySettings(SpeechSettings src) => src;
Ejemplo n.º 6
0
 public override SpeechSettings ModifySettings(SpeechSettings src) =>
 src with