I have the following script:
#!/usr/bin/env python
import sys
import pyttsx
def main():
print 'running speech-text.py...'
engine = pyttsx.init()
str = "Hi..."
if len(sys.argv) > 1:
str = sys.argv[1]
engine.say(str)
engine.runAndWait()
if __name__ == '__main__':
main()
and I have placed it in /usr/bin/speech-test.py
I have also given it executable permissions and ownership to root:
sudo chown root:root /usr/bin/speech-test.py
sudo chmod 4755 /usr/bin/speech-test.py
However, this script will only run correctly if I run as sudo speec-test.py
. If I try to run it as just speech-test.py
it complains about not finding a bunch of ALSA lib files.
Am I missing something to have my script run with root privileges?
env
in hashbang, but I need to test it. You call it like./speech-test.py
, not bypython speech-test.py
? Because later would run python still with user rights. – Trichromatismspeech-test.py
no ./ – Recuperateespeak
? – Corcyra