Build Text to Speech App in PyQt5

In this article we are going to learn that How to Build Text to Speech App in PyQt5, for this we want to use QtTextToSpeech module, first of all let’s talk about this module, according to the documentation QtTextToSpeech module enables a PyQt application to support accessibility features such as text-to-speech, which is useful for end users who are visually challenged or cannot access the application for whatever reason. In which case the application can read out the relevant text.

 

 

First we need to install some libraries, the first one is PyQt5, and also because we are using Qt Designer, we need to install PyQt5 Tools, make sure that you install PyQt5, because at the writing of this article, we don’t have this module in PyQt6.

 

 

Now we want to design our simple app for Text to Speech App.

  • Add QLabel, QLineEdit and a QPushButton, after that add Horizontal Layout
  • Add Another QLabel with QComboBox and make the layout Horizontally
  • Add Another QLabel with QSlider and make the layout Horizontally
  • At the end make the main window layout as vertically

 

 

Check Programming Videos in Geekscoders.com

 

 

 

This is the design at the end.

Build Text to Speech App in PyQt5
Build Text to Speech App in PyQt5

 

 

After that save your file in your working directory, it will be a .UI extension and now let’s convert our UI file to PY file, we can use pyuic5 module for converting our .UI file to .PY file.

 

 

This is the code for creating the engine and also finding the available voices for the engine.

 

 

 

Now let’s create our stateChanged method,  we have connected this at the top.

 

 

This is the method that we have connected this with clicked signal of the QPushButton.

 

 

 

This is the complete code for this lesson.

 

 

 

 

Run the complete code and you will receive this kind of UI with Text to Speech functionality in PyQt5.

PyQt5 Text to Speech
PyQt5 Text to Speech

Leave a Comment

Share via
Copy link
Powered by Social Snap