Ported to python 3....
 
Notifications
Clear all

Ported to python 3.7.3

3 Posts
2 Users
3 Reactions
859 Views
chrisbuy
(@chrisbuy)
Member
Joined: 6 years ago
Posts: 71
Topic starter  

I believe I have ported the base code to Python 3.x (in my case 3.7.3). Did someone else succeeded in doing this?

I had to ran the following commands to make Qbo start in Python 3.x... in short the 'print("...")' and 'except (error) as e:' (and some special stuff for snowboy) HotwordDetector in snowboydecoder). I am stuck now on Audio in QboTalk (which I posted in another thread).

 # Adapt for Python 3
sed -i 's/python2/python3/g' /opt/qbo/Start.py
sed -i 's/python /python3 /g' /opt/qbo/scripts/QBO_PiFaceFast.sh
sed -i 's/except (IOError, ImportError), e:/except (IOError, ImportError) as e:/g' /opt/qbo/web/panel/views/moves_views.py
sed -i 's/import thread/import _thread/g' /opt/qbo/PiFaceFast.py
sed -i 's/print"\(.*\)$/print("\1)/g' /opt/qbo/PiFaceFast.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/PiFaceFast.py
sed -i 's/ThreadedDetector/HotwordDetector/g' /opt/qbo/PiFaceFast.py
sed -i 's/snowboythreaded/snowboydecoder/g' /opt/qbo/PiFaceFast.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/assistants/QboDialogFlowV2.py
sed -i 's/python/python3/g' /opt/qbo/assistants/QboDialogFlowV2.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboGAssistant.py
sed -i 's/python/python3/g' /opt/qbo/assistants/QboMyCroft.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboTalk.py
sed -i "s/print '\(.*\)$/print('\1)/g" /opt/qbo/assistants/QboTalk.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/assistants/QboTalk.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboTalkMycroft.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboWatson.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/assistants/QboWatson.py
sed -i 's/print"\(.*\)$/print("\1)/g' /opt/qbo/controller/QboController.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/controller/QboController.py

--
Christian Buysschaert
Leuven - Belgium
Email christian.buysschaert@gmail.com


   
Quote
Topic Tags
Qbo Robot
(@nonogrub)
Member Admin
Joined: 8 years ago
Posts: 185
 
Posted by: @chrisbuy

I believe I have ported the base code to Python 3.x (in my case 3.7.3). Did someone else succeeded in doing this?

I had to ran the following commands to make Qbo start in Python 3.x... in short the 'print("...")' and 'except (error) as e:' (and some special stuff for snowboy) HotwordDetector in snowboydecoder). I am stuck now on Audio in QboTalk (which I posted in another thread).

 # Adapt for Python 3
sed -i 's/python2/python3/g' /opt/qbo/Start.py
sed -i 's/python /python3 /g' /opt/qbo/scripts/QBO_PiFaceFast.sh
sed -i 's/except (IOError, ImportError), e:/except (IOError, ImportError) as e:/g' /opt/qbo/web/panel/views/moves_views.py
sed -i 's/import thread/import _thread/g' /opt/qbo/PiFaceFast.py
sed -i 's/print"\(.*\)$/print("\1)/g' /opt/qbo/PiFaceFast.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/PiFaceFast.py
sed -i 's/ThreadedDetector/HotwordDetector/g' /opt/qbo/PiFaceFast.py
sed -i 's/snowboythreaded/snowboydecoder/g' /opt/qbo/PiFaceFast.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/assistants/QboDialogFlowV2.py
sed -i 's/python/python3/g' /opt/qbo/assistants/QboDialogFlowV2.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboGAssistant.py
sed -i 's/python/python3/g' /opt/qbo/assistants/QboMyCroft.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboTalk.py
sed -i "s/print '\(.*\)$/print('\1)/g" /opt/qbo/assistants/QboTalk.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/assistants/QboTalk.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboTalkMycroft.py
sed -i 's/python2/python3/g' /opt/qbo/assistants/QboWatson.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/assistants/QboWatson.py
sed -i 's/print"\(.*\)$/print("\1)/g' /opt/qbo/controller/QboController.py
sed -i 's/print "\(.*\)$/print("\1)/g' /opt/qbo/controller/QboController.py

Are you using snowboy?. Whats new?. Working in another "hotword" service. 


   
ReplyQuote
chrisbuy
(@chrisbuy)
Member
Joined: 6 years ago
Posts: 71
Topic starter  

@nonogrub

No, I am not using snowboy (yet)... I believe I only ported the existing (!) code to Python 3.7.3 so that it starts but due to an audio driver issue with a Raspberry Pi 4 Model B I am stuck experimenting if everything works accordingly (I'm failing on the first words Q.bo tries to speak). I did try headmovement seperately though and that works so the serial communication in Python 3.7.3 with the Arduino works.

--
Christian Buysschaert
Leuven - Belgium
Email christian.buysschaert@gmail.com


   
ReplyQuote
Share: