Speakers work by converting electrical energy into mechanical energy (motion). … In speakers, a current is sent through the voice coil which produces an electric field that interacts with the magnetic field of the permanent magnet attached to the speaker. Like charges repel each other and different charges attract.
from gtts import gTTS
# import Os module to start the audio file
language = ‘en’ # Select your Language
myobj = gTTS(text=mytext, lang=language, slow=False) # Google convert text to speech
myobj.save(“output.mp3") #save the audio file
os.system(“omxplayer output.mp3") #play the audio in omxplayer in raspberry pi
Here you can give an input text it will be convert to speech and say via speaker.