Motive There are different types of modules in python which not everyone knows so we thought of introducing them to you guys. Let's start! Note: This is not a tutorial of how to use these but is to show that these modules also exist and if you want to know more you can visit there own page and if you want us to explain leave a comment below. Links to there page are also given below. Hope you found something useful. 1.Wikipedia Yes, there is a module called Wikipedia in python, you can easily install Wikipedia by pip install wikipedia . We cannot rely on this module for advanced use. It was designed for ease of use and simplicity. Learn More Here . Here is a simple example: import wikipedia wikiPython = wikipedia.summary("Python", sentences=2) print(wikiPython) One big disadvantage is that it works only if the interne...
Motive
Like always just showing you about a new library and how to use it properly. Hope that this would be helpful for you guys!
The Project
We will be using the pyttsx3 library for text
to speech, so before we move on with the project we need to install the
library. As always we need to open our terminal and type
pip install pyttsx3 and wait for it to complete the installation in case you get any error related to win32 just install pywin32 by
pip install pywin32.
Now import pyttsx3 and initialize it with sapi5. sapi5 is a Speech API
developed by Microsoft.
We have two
voices preinstalled they are David and Zira so if we need to access those voices we first have to define them and set it as the engine property. You can even try printing the voices that you have.
Now that
we have set our voice we need to create a function to convert text to speech. That function would have one parameter called text, which is the text that would be converted to speech.
Now let's
test our code by calling the function and passing that one parameter as the
text that you need the program to speak as a string:
The program works but, I felt it to be too fast for me to hear so let's
decrease the speed:
Now it works fine!
The Full Code
If you have any doubts or errors in the program feel free to comment down below and I will respond as early as possible. And if I have made any mistake please feel
free to correct me in the comment box below. Don't forget to follow us for such python related content.
Thank You for your inspiration, sir!!!
ReplyDelete