Browse Source

upload artificial-voice.py

Coder 4 years ago
parent
commit
8e29981942
1 changed files with 28 additions and 0 deletions
  1. 28 0
      artificial-voice.py

+ 28 - 0
artificial-voice.py

@@ -0,0 +1,28 @@
+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')