Pergunta

I am developing an application with speech recognition in c# using windows forms. My system has 3D animated visual interface embedded in windows form application. The visual component is a COM component (ActiveX). The visual component is using text-to-speech (TTS) engine but to access TTS, I am using component's API. I am not directly using TTS by using SAPI. The TTS engine used by the visual component is the default TTS available on Windows. This visual component has an important limitation, it could not work on multiple cores. So when I start the application, I set CPU affinity to 1 core. Because everything is in the same form, all parts (i.e. graphical rendering, TTS, speech recognition and so on..) of the application runs using 1 core.

This component is rendering constantly some graphics to the screen, it is an intensive process and it never stops. In addition, in-process speech recognizer is running. When TTS is active, if user speaks to system, the applications freezes for some seconds then it returns to normal. I want to resolve this issue. I tried to set process of windows form to higher priority such as real-time, high, but it did not work.

I want to run in speech recognizer or COM component in different non-stopping thread than main winform thread. Any suggestions, similar samples might help.

Foi útil?

Solução

The Default TTS available on Windows is SAPI. By default, the TTS & SR engines run on a separate thread. However, the default SAPI TTS request will block the calling thread (unless the TTS request is made with the Async flag set). (SR requests will marshal back to the calling thread automatically.)

So, if the component is doing the TTS calls, you'll need to modify the component to make the TTS calls asynchronously.

You can also use thread affinity (aka the SetThreadAffinityMask API) to force the main thread to only run on one core. That may not fix the race conditions, though. Using process affinity (SetProcessAffinityMask) won't work, as it affects all threads, and you definitely need more than one thread.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top