2

I want to write a TTS program that automatically scrolls to the spoken word. I found a solution for paragraphs. I am not using paragraphs, but I adapt this solution to use the characterIndex of the current word:

        TextPointer startTextRange = richtTextselectionView.Document.ContentStart.GetPositionAtOffset(characterIndex);
        verticalOffset = startTextRange.GetCharacterRect(LogicalDirection.Forward).Y;
        richtTextselectionView.ScrollToVerticalOffset(verticalOffset);

This is the Result:

GIF of the current Program code. The scroll speed is too slow, and the viewport only reaches until eight instead of twelve

The Problem is that the text box is scrolling too slow.

I already tried to multiply the verticalOffset with a constant but the behavior seems to be nonlinear...

I am using .Net6.0 and MaterialDesignThemes in the latest version.

mtooling
  • 43
  • 6
  • Yes, I allow text input. I just used one, two, three as an example to demonstrate the problem. And yes, I would be also fine with a normal TextBox, but I couldn't find a good solution to highlight the spoken words. – mtooling Apr 17 '22 at 12:43

0 Answers0