12345678910111213141516171819202122232425262728293031 |
- #pip install gtts
- #pip install playsound
- from gtts import gTTS
- from playsound import playsound
- print('Virtual assistant:\n')
- txt = "Hello! How are you? Feeling good, bad, or okay?"
- voice = gTTS(text=txt, lang='en', slow=False)
- voice.save('1.mp3')
- playsound('1.mp3')
- response = input('You: ')
- if response.lower() == 'good':
- txt2 = "Great!"
- voice2 = gTTS(text=txt2, lang='en', slow=False)
- voice2.save('2.mp3')
- playsound('2.mp3')
- elif response.lower() == 'bad':
- txt2 = "Okay."
- voice2 = gTTS(text=txt2, lang='en', slow=False)
- voice2.save('2.mp3')
- playsound('2.mp3')
- elif response.lower() == 'ok':
- txt2 = 'Okay'
- voice2 = gTTS(text=txt2, lang='en', slow=False)
- voice2.save('2.mp3')
- playsound('2.mp3')
- else:
- txt2 = 'Dats invalid response bro!'
- voice2 = gTTS(text=txt2, lang='en', slow=False)
- voice2.save('2.mp3')
- playsound('2.mp3')
|