Skip to content

Commit

Permalink
Merge pull request #3 from appi147/pyttsx3
Browse files Browse the repository at this point in the history
Pyttsx3
  • Loading branch information
appi147 committed Oct 19, 2017
2 parents e850aa4 + 3dbe407 commit 1ab1c5e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 53 deletions.
28 changes: 0 additions & 28 deletions jarviscli/packages/audioHandler.py

This file was deleted.

29 changes: 7 additions & 22 deletions jarviscli/utilities/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
if IS_MACOS:
from os import system
else:
import pyttsx
import pyttsx3

'''
ABOUT: This class is the Voice of Jarvis.
The methods included in this class
generate audio output of Jarvis while
interacting with the user.
DOCUMENTATION on pyttsx:
https://pyttsx.readthedocs.io/en/latest/
DOCUMENTATION on pyttsx3:
https://pyttsx3.readthedocs.io/en/latest/
'''


class Voice:
def __init__(self):
"""
This constructor creates a pyttsx object.
This constructor creates a pyttsx3 object.
"""
if not IS_MACOS:
self.create()
self.engine = None

def create(self):
"""
This method creates a pyttsx object.
This method creates a pyttsx3 object.
:return: Nothing to return.
"""
self.engine = pyttsx.init()
self.engine = pyttsx3.init()
self.engine.setProperty('rate', 120)

def destroy(self):
"""
This method destroys a pyttsx object in order
This method destroys a pyttsx3 object in order
to create a new one in the next interaction.
:return: Nothing to return.
"""
Expand Down Expand Up @@ -68,18 +68,3 @@ def text_to_speech(self, speech):
self.engine.say(speech)
self.engine.runAndWait()
self.destroy()


'''
The following block of code is a test for this class.
In order to execute it run this script from the terminal
as: ~$ python Voice.py
'''

if __name__ == '__main__':
jarvis = Voice()
jarvis.speak(True)
text = ['Say hello to my little friend', 'What time is it',
'Welcome to Jarvis', 'I am trolling you']
for _ in text:
jarvis.text_to_speech(_)
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ beautifulsoup4==4.5.3
bs4==0.0.1
colorama==0.3.7
eyeD3==0.7.11
gTTS==1.1.8
gTTS-token==1.1.1
youtube-dl==2017.06.05
instantmusic==2.2
lxml==3.7.3
Expand All @@ -17,7 +15,7 @@ requests[security]==2.13.0
selenium>=2.33
six==1.10.0
SpeechRecognition==3.6.3
pyttsx == 1.1
pyttsx3
aiml
python-dateutil
mock==2.0.0
Expand Down

0 comments on commit 1ab1c5e

Please sign in to comment.