Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Convert PDF File Text to Audio Speech using Python
Next article icon

The following article shows how by the use of two modules named,pyttsx3 andPyDictionary, we can make our system say out the meaning of the word given as input. It is module which speak the meaning when we want to have the meaning of the particular word.

Modules needed

  • PyDictionary: Itis a Dictionary Module for Python 2-3 to get meanings, translations, synonyms and Antonyms of words. It uses WordNet for doing as its functionality suggests and has dependencies on modules named Requests, BeautifulSoup4 and goslate .
  • pyttsx3:It is a text to speech library. This module is what gives our system voice so that they can communicate with us. Pyttsx3 uses sapi5 in windows and espeak in windows.

Both modules can be installed by using pip in the following way:

pip install PyDictionarypip install pyttsx3

Working

As mentioned above, by the combination of two modules we will generate the functionality required and to do that the following steps were taken:

  • A method is defined to make the system search for the meaning of the word provided as input
  • Another method is defined to make the system say out loud the output generated corresponding to the input provided.
  • The output returned in this may be a dictionary, so we have to extract each meaning of the word provided as it will be in a key-value format.

Below is the Implementation.

Python3
importpyttsx3fromPyDictionaryimportPyDictionaryclassSpeaking:defspeak(self,audio):# Having the initial constructor of pyttsx3# and having the sapi5 in it as a parameterengine=pyttsx3.init('sapi5')# Calling the getter and setter of pyttsx3voices=engine.getProperty('voices')# Method for the speaking of the assistantengine.setProperty('voice',voices[0].id)engine.say(audio)engine.runAndWait()classGFG:defDictionary(self):speak=Speaking()dic=PyDictionary()speak.speak("Which word do u want to find the meaning sir")# Taking the string inputquery=str(input())word=dic.meaning(query)print(len(word))forstateinword:print(word[state])speak.speak("the meaning  is"+str(word[state]))if__name__=='__main__':GFG()GFG.Dictionary(self=None)

Output:


Article Tags :
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp