Repository: nvaccess/nvda

Issue:
LH TTS Speech Engine for SAPI5 Is Not Working Correctly With Speech Refactor
<!--
Please thoroughly read NVDA's wiki article on how to fill in this template, including how to provide the required files.
Issues may be closed if the required information is not present.
https://github.com/nvaccess/nvda/wiki/Github-issue-template-explanation-and-examples
-->

### Steps to reproduce:
1. Install the LH TTS voices, you can get them in several ways, either with Office 2003 or by installing Microsoft Reader.
2. Switch to SAPI5 and switch to one of the voices, LH Michael or LH Michelle.
3. Save the settings then go to the Desktop.

### Actual behavior:
NVDA only says the first chunk of text sent to the synthesizer, such as "Folder View List", and it does not speak the selected icon.

### Expected behavior:
As well as saying "Folder View List, NVDA should say the selected icon just as it does when using other SAPI5 voices.

### System configuration
#### NVDA installed/portable/running from source:
NVDA is installed.

#### NVDA version:
2019.3.1

#### Windows version:
Windows 10 19H2 (10.0.18363)

#### Name and version of other software in use when reproducing the issue:
No other software other than the TTS voice is being used.

#### Other information about your system:
A similar issue of this type was fixed for SAPI4 in current Alpha builds, so I'm guessing that a similar fix would have to happen for the SAPI5 driver, but I'm not entirely sure.

### Other questions
#### Does the issue still occur after restarting your computer?
Yes.

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
All versions of NVDA prior to 2019.3 work correctly in this scenario.

#### If addons are disabled, is your problem still occuring?
Yes.
#### Did you try to run the COM registry fixing tool in NVDA menu / tools?
No, as this issue doesn't persist in other versions of NVDA and it's just with a text-to-speech voice.


Discussion:
See also: PR #10792
Hello,

I just posted on the issue you mentioned, but that one's for SAPI4. I indirectly referenced that issue in my original report.

I'm guessing something similar could be done for SAPI5.

Thanks,

Brandon

Resolving patch:
diff --git a/source/synthDrivers/sapi5.py b/source/synthDrivers/sapi5.py
--- a/source/synthDrivers/sapi5.py
+++ b/source/synthDrivers/sapi5.py
@@ -1,9 +1,9 @@
 # -*- coding: UTF-8 -*-
-#synthDrivers/sapi5.py
-#A part of NonVisual Desktop Access (NVDA)
-#Copyright (C) 2006-2017 NV Access Limited, Peter Vágner, Aleksey Sadovoy
-#This file is covered by the GNU General Public License.
-#See the file COPYING for more details.
+# synthDrivers/sapi5.py
+# A part of NonVisual Desktop Access (NVDA)
+# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy
+# This file is covered by the GNU General Public License.
+# See the file COPYING for more details.
 
 import locale
 from collections import OrderedDict
@@ -364,6 +364,11 @@ def outputTags():
 		tagsChanged[0] = True
 		outputTags()
 
+		# Some SAPI5 synthesizers complete speech sequence just after the last text is said
+		# and ignore any indexes passed afterward.
+		# Therefore we add the pause of 1ms at the end of each sequence.
+		textList.append('<silence msec="1" />')
+		# Join textList to create xml document passed to synthesizer
 		text = "".join(textList)
 		flags = constants.SVSFIsXML | constants.SVSFlagsAsync
 		self.tts.Speak(text, flags)


Test patch: