User avatar
with ice cream
Posts: 173
Joined: Mon Jul 30, 2012 7:25 am

Audio problems (command line vs. CGI script)

Sat Aug 04, 2012 5:06 am

I have espeak working properly from the command line (all audio-related tweaks for output via headphone jack are in place) but it fails when called from a simple CGI script.

The script:

Code: Select all

#!/bin/sh

/usr/bin/espeak $QUERY_STRING
Usually, when I run espeak from the command line I get some errors but they seem to be negligible:

Code: Select all

ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playba                                       ck stream
ALSA lib pcm_direct.c:877:(snd1_pcm_direct_initialize_slave) slave plugin does n                                       ot support mmap interleaved or mmap noninterleaved access
ALSA lib pcm_dmix.c:1030:(snd_pcm_dmix_open) unable to initialize 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
Yet, when I run the script I find this in apache2's error log:

Code: Select all

[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:768:(parse_card)
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] cannot find card '0'
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34]
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate)
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] function snd_func_card_driver returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34]
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM sysdefault
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM sysdefault
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM dmix
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM dmix
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] Cannot connect to server socket err = No such file or directory
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] Cannot connect to server request channel
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] jack server is not running or cannot be started
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] wave_open_sound > Pa_OpenStream : err=-9996 (Invalid device)
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] wave_open_sound > Pa_OpenStream : err=-9996 (Invalid device)
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] wave_open_sound > Pa_OpenStream : err=-9996 (Invalid device)
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] wave_open_sound > Pa_OpenStream : err=-9996 (Invalid device)
[Sat Aug 04 07:00:11 2012] [error] [client 192.168.178.34] Premature end of script headers: speak.cgi
User www-data is member of the group audio. I already tried it running with user pi and I also tried it adding the line "amixer cset numid=3 1".

What am I missing?

User avatar
with ice cream
Posts: 173
Joined: Mon Jul 30, 2012 7:25 am

Re: Audio problems (command line vs. CGI script)

Sat Aug 04, 2012 5:42 am

Forget it. I guess the only thing I needed was the group assignment to become active. A reboot did that.

Return to “Graphics, sound and multimedia”