CapnWinky07 wrote: ↑Tue Oct 31, 2017 1:16 am
It's possible. Would it be shooting up these errors in that case?
Code: Select all
rec FAIL formats: can't open input `default': snd_pcm_open error: No such file or directory
play FAIL formats: can't open input pipe `|rec --buffer 2048 -d pitch -300 echos 0.8 0.88 100 0.6 150 .5 band 1.2k 1.5k': premature EOF
That's what's perplexing me.
That's exactly the error you'd get if the requested device doesn't exist.
CapnWinky07 wrote: ↑Tue Oct 31, 2017 1:16 am
I do
Add this line:
Code: Select all
@reboot sh /home/pi/voicechanger.sh > /home/pi/voicechanger.log 2>&1
My voicechanger.sh simply says:
Code: Select all
play "|rec --buffer 2048 -d pitch -400"
If I just run that in a command prompt, everything works fine. So I don't think it's the mic/speaker/usb card.
It works at the command prompt because the audio card will have been detected and set up by the time you get to type anything. Running from cron @reboot you can't guarantee that the services you require have been started before you. Try adding a check to the start of your script and keep waiting until it is seen.
Code: Select all
#!/bin/sh
# If card1 doesn't exist wait for 5 seconds and try again
while [ ! -d /proc/asound/card1 ]; do
sleep 5
done
# We should have the sound card now so can use it
play "|rec --buffer 2048 -d pitch -400"
Adjust the delay according to your needs, I've given it 5 seconds between checks, don't want to be constantly checking whilst the system is busy booting up.
Although cron isn't really the best place to be doing this, you might be be better off creating a
systemd service, that way you should be able to get
systemd to only run it after the sound card has appeared if you set its requirements,
Code: Select all
[Unit]
Requires=sys-devices-?????sound-card1.device
After=sys-devices-?????sound-card1.device
To get the actual name (I put ????? for the bit I don't know) run the following, it should list the sound device services that are active (card0 will be the built-in audio, you want the name of card1).
Code: Select all
systemctl status sys-devices-*sound*