Refactor TTS logic in Select to Speak
Refactored the underlying logic of STS. Previously, STS combines node enqueue, navigation control, and TTS playing in one function (i.e., startSpeechQueue_). I separate these functionalities by adding five navigation state variables. Then, enqueue nodes in startSpeechQueue_, play TTS via startCurrentNodeGroup_, and control navigation by manipulating the navigation state variables. With this CL, STS will enqueue content to TTS one nodeGroup at a time. Previously, STS enqueued all selected nodeGroups to TTS. To reflect this change, I modify the tests. More details notes: 1. Refactor function updateNodeHighlight_ as we don't need the opt_endIndex in this function. 2. Create function syncCurrentNodeWithCharIndex_, which reuses code logic from the previous function onTtsWordEvent_. 3. Split function startSpeechQueue_ into (1) startSpeechQueue_, (2) startCurrentNodeGroup_, and (3) startNodeGroupAfter_. Function startSpeechQueue_ adds new content to the speaking queue and starts TTS using startCurrentNodeGroup_, which starts reading the current NodeGroup based on the five navigation state variables. Function startNodeGroupAfter_ allows us the change the navigation state variables to the next NodeGroup. AX-Relnotes: N/A Bug: 1143817 Change-Id: I1aa719786108e0f98fda36ebade7536967cfd2ce Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565698Reviewed-by:Dominic Mazzoni <dmazzoni@chromium.org> Reviewed-by:
Akihiro Ota <akihiroota@chromium.org> Commit-Queue: Lei Shi <leileilei@google.com> Cr-Commit-Position: refs/heads/master@{#833620}
Showing
This diff is collapsed.
Please register or sign in to comment