我需要在系统开始时使用espeak
。所以我将以下命令添加到 /etc/rc.local
espeak "hello" >>/etc/start.log 2>&1
然后,它不起作用并记录以下错误:
ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->playback, outParams, self->primeBuffers, hwParamsPlayback, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2722
......
(more)
然而,如果我把命令放到bash配置文件中,一切都会好的(但我不想把它放在这里用于其他目的)
我试图找到问题,并认为音频硬件可能无法在启动时初始化
所以我写了一个简单的python脚本
import time, os
time.sleep(300)
os.system("espeak 'hello 123'")
并添加到 /etc/rc.local
nohup python3 -u /home/xxx/test.py >> /home/xxx/log.log 2>&1 &
不幸的是,我收到了相同的错误。我还试图通过python脚本启动一个简单的http服务器,并在某个请求时调用os.system("espeak 'hello 123'")
,但我得到了相同的错误。我也在另一台PC上试过这个,但我也得到了相同的错误
这真的很荒谬,令人难以置信。任何人都可以帮我解决问题吗?
(抱歉英语不好)