Sapi5 on linux? - python

I am working on creating an AI for myself and I chose python as the programming language to code it in. I am an absolute beginner in programming and have very little knowledge of the subject. After spending months of coding I finally created an AI by myself that is able to run and I did so on windows. I wanted to move this program to a raspberry pi but turns out that I am unable to use Sapi5 TTS module from pyttsx3 on linux as it requires the win32com files to function. I am aware that pywin32 cannot be run on linux as it is a different OS and I want to know if there is a way for me to be able to run sapi5 on linux? I have tries using different tts modules such as espeak but they are too robotic and I really like sapi5 so it would be great if there was a way for me to be able to use it, thank you for your time!!

Sapi5 is a built-in part of Microsoft Windows and you can't run it in Linux. I agree it's a pretty good speech synthesizer. You may consider using Mycroft/mimic, though I found the build process tricky, or use gTTS if your utterances are short and you'll have internet access.

Related

How to get libCEC for Python (PyCharm on Windows)?

I am unfortunately an absolute beginner in programming.
First of all, I'm programming with the PyCharm IDE on a Windows computer, but the script will later run on a RaspberryPi.
I want to turn on my TV with a Python script via HDMI-CEC and I came across libcec.
However, I can't figure out the setup instructions for Windows.
https://github.com/trainman419/python-cec
Can anyone give me a step by step guide on what exactly I need to do to use the CEC commands in Python?
Or should I program with PyCharm directly on the RaspberryPi? This one is way too slow for this task in my opinion. Then I could install the CEC library very easily.
Thanks for your help.

How do I deliver ready-to-run software?

Recently I've been developing Python code as a freelancer. I've mostly worked on social media bots, my usual way of delivering the code is as a Python script for people to run on their compilers. However, I've started to run into people that lack the technical knowledge of installing modules and running the code that way. How do I create a package like software and deliver it in a way that can be ready-to-run and users don't have to download anything extra? Thank you in advance for your feedback.
Check out py2exe. It is a wrapper that converts your script into an executable, so the user can run it without needing to install any python libraries.
Alternatives to py2exe are:
PyInstaller - the advantage of using this is that it lets you build executables in formats other than exe, if you want to make your program run on non-Windows platforms, for example.
cx_Freeze - this is also another cross-platform alternative.
One method would be (as stated in the previous answer) is to use exe converters, but that wouldn't be as effective if you target Mac and Linux users as well.
My solution is going to take you a little more time, but it will be worth it. Here goes:
Please learn Angular JS, or some other framework (I prefer Angular). Once you know that, you can easily develop a web app for your project, and add your Python to that.
The good news is, there are lots of tutorials for this, such as https://codehandbook.org/creating-a-web-app-using-angularjs-python-mongodb/ (also teaches you mongodb) Anyways, you can find other tutorials on your own.
You could of course, I guess, build it into a mobile app, but I think web app would be easier.

How to protect my Python scripts on Raspberry Pi?

I have developed a long and complex computer vision algorithm on Python. I insist on the "long and complex" because my very last solution would be to rewrite it with C++ (it's about 3 000 lines long and depends on pure Python libraries)...
This algorithm is embedded on a Raspberry Pi A+. It is possible to plug an SD card to this nanocomputer, so that it includes a Linux system.
So basically my script is in a folder in that SD. When the Raspberry Pi is switched on, it runs the system and then executes my code.
Let's say someone retrieve this SD card. How can I be sure that he won't be able to get to my script ?
I've read it was difficult to obfuscate Python code, is it still true ? Let's say I would rename all of my variables with absurd names, to "scramble the tracks". Are there programs that can retrace the structure of the whole algorithm ?
Regarding the SD card itself, is it possible to protect it ?
What I am actually doing is I deactivate the HDMI and USB port when the Raspberry Pi is launched, and protect the SSH connexion with a password.
Do you think this is enough, or is there other ways someone can get to the script ?
Finally, rewritting it in C++... Would it ensure me that it would be 100% protected ?!
Thank you in advance. :)
I think your best solution would be to compile your Python file using a bundling tool.
See Compiling Python Code.
For example using PyInstaller
pip install pyinstaller
pyinstaller yourprogram.py
Although you can never (even with C++) guarantee full "protection". There are techniques like reverse engineering that can be used to reveal your algorithm.

Where do I begin learning to program bots?

I don't know what they're called but I want to learn to program bots that perform tasks within a game or software. But I have no idea how to even make a program that does stuff on other programs/software/games. Are their any good books on the subject?
If it makes a difference I'm using a Linux OS. I know Python and I began learning C recently.
Thanks!
There are many tools for sending artificial input. My favorite one only works on Windows.
For the cross platform, including Linux, there is a library called autopy. As you can guess, it's a Python library and it allows you to access your keyboard and mouse through Python objects.
If you want to automate requests and parsing, Python has packages urllib2 and BeautifulSoup (specifically for parsing).

What is the best way to manage multiplatform video stream using Python?

I have this question in my head for over a year now. And I guess you guys may have the answer.
In some Python GUI app, I need to display a video stream.
I need to record some part of this stream to reread it later.
Moreover, I need to make this python application multi platform (OSX, GNU, Windows)
I am open to many solutions :
Connect the camera to a stream and read the stream with the python app. (RTP + VLC could do the trick)
Use Phonon to read the camera
Create an abstract class to define differents reader and use Quicktime, Win32 or GStreamer in function of the OS.
What is your experience, what would you use to do that ?
I've looked into this periodically as well, and it seems the complexity of the underlying task is just too high to have a simple shortcut abstraction library for your topic question. I would suggest using pyopencv for the specific task you articulate, however. It has a class for webcam input/capture which works across platforms and has a reasonable user-base, in python, posting examples. The latest is 2.3.1 and quite recent. You can get a windows version of it, compiled for you, on the unbelievably helpful site (not mine, just saying):
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Since you ask for experience with a few libraries, I'd say: gstreamer worked for me on linux but was a huge pain to setup on windows and didn't work for me. This was quite some time ago and perhaps it's working better now. vlc.py is a simple library to test and see whether vlc would work for you. It doesn't work on 64 bit windows platforms at the moment; not sure why, but it seems many have reported similar errors, so it depends on how much cross-platform support you need.
Unfortunately, this is not easy to do. I've written most of a program that does video recording/playback on the 3 major desktop OS's. The state of video playback/recording in a "out-of-the-box" way is still unsolved for cross-platform, other than HTML embedding. This has a lot to do with the fact that:
Codecs are proprietary
OS's don't support common codecs
ffmpeg and similar projects have licenses that require you to release your source code if you include them in certain ways
A lot of the video playback players that exist are each rewritten by hand to handle each frame, buffering, streaming, audio sync'ing, and the like.
So you can go with HTML, or you can suffer through the cross-platform issues with the following coding libaries:
Python mplayer
Python vlc
Python opencv
Python pyaudio
Python pyside/pyqt phonon or qtmultimedia
Once you get it working on one development machine, expect it to break when it comes to installation on the end-user machine (distribute via: pyinstaller / appdmg / apt / chocolatey / Inno Setup )
On OSX, brew still has a lot of issues with this, but macports works better (I still had to do a lot of patching)
Linux is by far the easiest.
Windows is in-between the to as far as difficulty
I'd be eager to hear how iOS / Android / Windows RT / Kindle are
The problem is not unique, as even Netflix has yet to have a cross-platform video app: https://www.quora.com/Is-Netflix-building-an-app-for-the-Mac-App-Store?share=1

Categories

Resources