How to Use Text to Speech in Qt for Windows

Unfortunately for Cross-Platform developers, there is no standard method or API that you can code once and use to have TTS (Text to Speech) in your programs. You may find some 3rd party libraries that allow a great deal of reusability in different Operating Systems but at some point they also prove to do less than what you require. Qt has promised to make this available for us in the near feature but it has been postponed all the time. The main reason is that there is a huge race between major Software companies (Microsoft, Google and Apple) in this field and it seems that they somehow make it work in totally different ways on purpose. So anyway that is why I decided to share the method to have TTS in Qt in all well known operating systems and I am going to start with the easiest one, which is Windows.



In Windows you can use SAPI (Speech API) to have TTS (Text to Speech) in your applications. It offers quite easy and useful functions to enable TTS and let your programs speak. To demonstrate this I have created an example project with a simple user interface that you can see here:

Qt TTS

The main idea is to use ISpVoice class’s speak() method. Use the button below to download the example source code (complete project) and executable (Built with Qt 5.5.1 MSVC2010 32bit)

Download

If you have any issues building or running the project please let me know by commenting here.



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.