Refactoring to Python 3 and Object Oriented Design
tanay1337 opened this issue · comments
The codebase needs to be updated to Python 3 along with the implementation of Object Oriented Design.
@emedvedev For the Object Oriented Design part.
Could you please discuss the approach you will work for this because I have some other alternative here.
https://github.com/kivy/plyer in this project first some facade/example is made having classname and methods
ex. class TTS
and method def speak(self)
which initially set to NotImplementedError
to implement feature concerning it. And then we make different implementations concerning each platform like
- Windows : in win dir we create
tts.py
and inheritsTTS class
with overridingspeak
method with corresponding implementation for windows.
Similarly,linux
dir for linux andtts.py
inheritingTTS
class again with its implementation.
If looks good then would like to work on it as I have already contributing to that project.
Thanks !!
@bhaveshAn sounds good to me. Here's what you can do:
- Add an empty TTS class.
- Create a structure as you have proposed, i.e.
tts/<engine>/main.py
(I would prefermain.py
totts.py
for readability: if there's many files,main
is a much clearer entry point). - Use a dynamic import with
import_module
to load the engine specified in the user config file.
You're welcome to work on it. Later we'll use a similar approach for actions, too.
Create a structure as you have proposed, i.e. tts/ engine /main.py
From engine do you mean espeak
/ say
Like to create tts/espeak/main.py
and tts/say/main.py
Or please elaborate if I am getting wrong.
Yes, you're getting it right. :)
@emedvedev
I have to make a PR in WIP.
Since there is huge change in codebase, so will it be good to make a new branch in upstream say py3
so that it may not affect current codebase which is on py2
What say.
Could you make one?
I would like to work on this
@emedvedev
For OOD, we have made objects for tts as
config.py
tts_engine = SayTTS()
or tts_engine = EspeakTTS()
# depending on platform
Earlier, we are using WORDS
const
Example: WORDS = {'news_reader': {'groups': [['business', 'news']]}}
for business_news_reader module.
But for actions it would better to switch to NLP instead of WORDS
const as mentioned earlier.
Like,
business_news = BusinessNewsReader()
user_query = 'something asking to melissa'
if 'business' in nltk.tokenize.word_tokenize(user_query) and 'news' in nltk.tokenizeword_tokenize(user_query):
business_news.news_reader(user_query)
etc for other action modules.
What say.
For the part of Refactoring to Python 3
I tried to install deps for python3 locally from requirements.txt
- only poster==0.8.1 was not been processed as it only supports py2 as of now.
While all the other deps were installed properly. - every
print "text"
syntax is required to change toprint()
Can I work on this if its still pending ?