Let's look how we can achieve this :
Install pywin32 module - Install pywin32 python module from terminal in order to use a voice that will read out the texts.
Codes And It's Explanation :-
from win32com.client import Dispatch s = Dispatch("SAPI.spVoice") s.speak("Coding Beast")
from win32com.client import Dispatch - Import Dispatch function from the win32com.client module, which is part of the pywin32 library. This library allows Python to interact with COM (Component Object Model) objects, enabling the automation of Windows applications and services such as Microsoft Office (Excel, Word, Outlook), Internet Explorer, and many others.
s = Dispatch("SAPI.spVoice") - The line Dispatch("SAPI.SpVoice") is used in Python to create an instance of the SAPI.SpVoice object, which is part of the Microsoft Speech API (SAPI). This allows your Python program to use text-to-speech (TTS) capabilities to convert text into spoken words.
s.speak("Coding Beast") - s.speak() functions speaks whatevery string you give inside it.