%T#13972 Task opened by lenzone10: Rockbox Utility: fix voice creation crash and unreliable SAPI5 synchronization (Attachment added)

Rockbox via rockbox-sf <[email protected]> Tue, 04 Aug 2026 15:04:14 +0000
Newsgroups gmane.comp.systems.archos.rockbox.sourceforge
Message-ID <[email protected]>
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

A new Flyspray task has been opened.  Details are below. 

User who did this - Alessio Lenzi (lenzone10) 

Attached to Project - Rockbox
Summary - Rockbox Utility: fix voice creation crash and unreliable SAPI5 synchronization
Task Type - Patches
Category - Rockbox Utility (rbutil)
Status - Unconfirmed
Assigned To - 
Operating System - All players
Severity - Media
Priority - Molto Bassa
Reported Version - Daily build (which?)
Due in Version - Undecided
Due Date - Undecided
Details - Current Rockbox Utility master can crash while preparing voice corrections and
can hang or fail during SAPI5 voice generation on Windows. The changes are
attached as three separate .dif files, one for each modified source file. The
three diffs were tested together.

Base revision:
ab863dc40c3091adf5d11486ab59dbdcae82bbe6


Fix 1: keep the voice-corrections file alive
=============================================

File:
voicefile.cpp.dif

VoiceFileCreator::createVoiceFile() stored corrFile as the address of a local
QTemporaryFile (or a local QFile used as fallback). Both objects were destroyed
before VoiceFileCreator::create() called TalkGenerator::setLang(), leaving a
dangling pointer.

On Windows this produced an access violation in RockboxUtility.exe immediately
after the voice strings had been read. Windows reported exception 0xc0000005.

The change gives the corrections file QObject lifetime under VoiceFileCreator,
uses the built-in corrections file as a persistent default, and replaces it
with a persistent extracted QTemporaryFile when extraction succeeds.


Fix 2: make the SAPI5 protocol reliable
=======================================

Files:
ttssapi.cpp.dif
sapi_voice.vbs.dif

The existing code treated any ready-read notification from cscript as proof
that synthesis had completed. The SAPI script can emit other output, so the
Utility could check for the wave file before the explicit SYNC reply and report
that the output file did not exist.

The script also used global "On Error Resume Next" without reporting errors
from SpFileStream.Open(), SpVoice.Speak(), or SpFileStream.Close(). Several
waits had no timeout, allowing the GUI thread to remain blocked indefinitely.

The changes:

* reports SAPI COM errors to Rockbox Utility;
* verifies that SAPI actually created the requested wave file;
* waits for the explicit SYNC reply instead of any process output;
* applies finite timeouts to vendor queries, synthesis, and shutdown;
* terminates a stuck private cscript process safely;
* restarts cscript and retries the current string up to three times when a
  third-party SAPI engine stops responding during a long generation run.


Reproduction before the changes
===============================

1. Run current Rockbox Utility on Windows.
2. Configure an iriver H340 and select the Italian language.
3. Select the SAPI5 engine and a registered Italian SAPI5 voice.
4. Start voice-file creation.

Observed outcomes included:

* a crash after reading the voice strings, before the first wave file;
* the first wave file being reported missing despite the SAPI process replying;
* an indefinite GUI hang during the TTS test or SAPI shutdown;
* a long generation run failing when a third-party voice stopped responding
  after many successful strings.


Verification after the changes
==============================

Build environment:

* Windows, 64 bit
* Qt 6.8.3
* MinGW 13.1.0
* Rockbox Utility built from the base revision above

Test target:

* iriver H340 (target id 10)
* installed Rockbox build ab863dc40c-260802
* voice format 400
* Italian voice file generated from the installed voicestrings.zip

SAPI voices tested:

* Vocalizer Expressive Luca Harpo 22 kHz (licensed local SAPI5 voice)

Results:

* a complete Italian voice file was generated with Luca;
* the generated voice file was accepted and used by Rockbox on the H300;
* a real intermittent timeout during the Luca run was recovered by restarting
  cscript and retrying the current string;
* Rockbox installation/update through the same Utility build also completed
  successfully.


Known separate issue
====================

Voice generation still runs synchronously from the GUI's point of view. During
long runs, the interface is difficult to navigate with a screen reader and
cancellation is not responsive enough. This is not addressed by these changes
and should be handled separately, most likely by moving generation work off
the GUI thread.


One or more files have been attached.

More information can be found at the following URL:
https://www.rockbox.org/tracker/task/13972

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
-- 
rockbox-sf mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-sf