Description
The problem
Currently the say() function does not return a value and is asynchronous, meaning it is not possible to reliably track utterance completion. The current speech is stopped if currently active when say() is called. However, the API has not been designed in such way that the state transitions guaranteed the same pattern (Ready -> say() -> Speaking -> say() -> ?). This makes utterance completion tracking difficult and unreliable at application level. This can be implemented in the application to some extent, but fallback measures such as watchdog timer (for tracking state transitions) are necessary to ensure reliability.
The solution
Add queue() function and a completion signal for the utterance.
int queue(const QString &text); Q_SIGNALS: void utteranceCompleted(int utteranceId);
The new queue() function would not stop the current speech, but would add the text to internal queue and dispatch it to the engine when the engine state becomes Ready. In case of errorneous state, the function would return 0 indicating an error. A positive integer would be allocated as utterance id which the application can store. The utterance completion would be signaled by utteranceCompleted(int) function. Only successful completion is signaled.
In case of say() and queue() calls are mixed:
- say() stops the current speech and clears the queue, no utterance completion signal is sent as the utterances were not finished.
- queue() waits until the current speech is finished, no completion signal for the utterance started by say().