Reputation: 275
Im developing an application on my raspberry Pi 3, using gTTS for Python:
from gtts import gTTS
import os
import threading
def greet_thread(word):
tts_thread = threading.Thread(target = greet, args=[word])
tts_thread.start()
def greet(word):
tts = gTTS(text=word, lang='es')
tts.save("words.mp3")
print 'Reproduciendo audio'
os.system("mpg321 -q presilence.mp3")
os.system("mpg321 -q words.mp3")
This works perfectly if i run the python script directly from a shell. But if i execute the python script in background using:
python -u script.py > log.txt 2>&1 &
i get this error in my log:
tcgetattr(): Inappropriate ioctl for device
and don't know why. I think is the way it's called from a background process, but no idea how to solved it. Thanks for your attention and help
Upvotes: 2
Views: 909
Reputation: 11
I was having a similar issue with calling mpg321 from a python script that was launched from a bash script via crontab on reboot. I was getting the vague error: tcgetattr(): Inappropriate ioctl for device
After digging thru numerous threads and trying everything I could, I changed to use omxplayer
instead and it seems to have solved the issue.
Best I can tell it was some kind of permissions issue with launching from crontab because I could run it without any issue from a terminal session.
Upvotes: 1
Reputation: 275
The problem is that the program needs to be executed using the same user that executes the GUI. So if you are going to execute it in a command shell, avoid using 'root' user.
In my case i need the program executes on start up too. So i solved it using "auto start" instead of a crontab
Edit the file:
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
//your script.sh
//or @python script.py
@xscreensaver -no-splash
@point-rpi
Save and exit
Reboot
Upvotes: 1