How to Build Text to Speech App with Python & PyQt5

In this article we are going to learn that How to Build Text to Speech App with Python & PyQt5, for this we want to use QtTextToSpeech module, the 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 of all open your Qt Designer, by default we don’t have Qt Designer in PyQt5, you need to install PyQt5 Tools.

 

 

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

 

 

This is the design at the end.

How to Build Text to Speech App with Python & PyQt5
How to Build Text to Speech App with Python & 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.

 

 

 

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.

 

 

 

 

And this is the complete code for the article.

 

 

 

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

Text to Speech Python and Pyqt5
Text to Speech Python and Pyqt5

 

 

Learn More on TKinter

Leave a Comment