ohos: Use tts proxy in qt speech engine
Create TextToSpeechProxy instance in QTextToSpeechEngineOhos
and implementation of with TextToSpeechProxy::EngineEventsListener
interface.
TextToSpeechProxy is a wrapper around JS speech API. It will be used
to call all JS methods related to speech.
TextToSpeechProxy::EngineEventsListener as a class that allows
to register clients callbacks called in JS API.
In future commmits TextToSpeechProxy::EngineEventsListener will
call QTextToSpeechEngineOhos methods. Each callback from
TextToSpeechProxy::EngineEventsListener (on"Action") will have
corresponding method in QTextToSpeechEngineOhos
(handleOn"Action").
The listeners are required to deliver events (onStart, onComplete,
onStop, onError) from the JS TTS engine back to the Qt side.
Pass ptr of listeners into TextToSpeechProxy. This ensures
that if QTextToSpeechEngineOhos is destroyed, the listeners will
no longer be invoked, avoiding potential use-after-free issues when
events are delivered asynchronously from the JS thread.
The engine has to be created with a language, which is hard coded to
"zh-CN" for now. According to Huawei doc:
https://developer.huawei.com/consumer/en/doc/harmonyos-references/hms-ai-texttospeech#createengineparams
"Language. Currently, Chinese and English are supported. zh-CN is
recommended for Chinese. zh_CN can also be used. For the English
language, en-US is recommended and en_US can also be used." Chinese is
picked as the default, since it is the only language for which the
system provides voices out of the box.
Task-number: QTBUG-147179
Pick-to: 6.12
Change-Id: I509f06dfc534ed8b58974137e8ad51654fdbfc6a
Reviewed-by: Zbigniew Chyla <zbigniew.chyla@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>