I am making a script that takes a random word and gets the definition of the word, then it would convert it into speech and play it, but for some reason whenever I try to get the definition of the word it just returns false, is there any way to fix this?
Note: I am using vocabulary to get the definition of the word and random words to get the random word that is going to be defined.
Script:
from gtts import gTTS
import subprocess
import time
import os
from random_word import RandomWords
from vocabulary.vocabulary import Vocabulary as vb
#Defining some variables and stuff
r = RandomWords()
#this gets the random word and checks if it has a dictionary definition, and makes the audio file
randword = r.get_random_word(hasDictionaryDef="true")
file = randword+' Definition.mp3'
#this part gets the meaning and converts the meaning into a string so it can say the text
todefine = vb.meaning(randword)
texty = str(todefine)
#What makes the text, then plays it
def PlayText():
#this part makes the file
language = 'en'
myobj = gTTS(text=texty, lang=language, slow=False)
myobj.save(file)
time.sleep(1)
#these prints are for debugging, randword is the random word, todefine is the definition
print(randword)
#texty is probably false, unless this has been fixed, and actaully define sthe word.
print(texty)
subprocess.call(file, shell=True)
#this just calls the function where everything is happening
PlayText()
Thanks for reading this, and if you tried to help, super thanks!