zaf / asterisk-googletts

Asterisk AGI script that uses Google's translate text to speech service.
GNU General Public License v2.0
214 stars 125 forks source link

Cannot locate installed sox or mpg123 #33

Closed phrohdoh closed 7 years ago

phrohdoh commented 7 years ago
root@arsenic2:# which sox
/usr/bin/sox

root@arsenic2:# which mpg123
/usr/bin/mpg123
    -- Executing [s@kazoo-test-taryn:1] Answer("SIP/kazoo-00000004", "") in new stack
    -- Executing [s@kazoo-test-taryn:2] AGI("SIP/kazoo-00000004", "googletts.agi,"This is a simple google text to speech test in english.",en") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/googletts.agi
 -- googletts.agi: sox or mpg123 is missing. Aborting.
Died at /var/lib/asterisk/agi-bin/googletts.agi line 362, <STDIN> line 24.
    -- <SIP/kazoo-00000004>AGI Script googletts.agi completed, returning 0
    -- Auto fallthrough, channel 'SIP/kazoo-00000004' status is 'UNKNOWN'
[Dec 22 11:10:28] NOTICE[49589]: pbx_spool.c:426 attempt_thread: Call completed to SIP/kazoo/1972XXXXXXX

(!$sox || !$mpg123) should probably use &&.

zaf commented 7 years ago

This test is there to make sure that both sox and mpg123 are found and are available for use. If we change that to (!$sox && !$mpg123) it will only be true, and generate a warning, if both sox and mpg123 are missing but it wont generate any warning if only one is missing.

zaf commented 7 years ago

Regarding the failure to detect the binaries in your system, can you please provide some more info like: OS/Distro And the output of: whereis which whereis sox whereis mpg123

Also the user that invokes the script and if possible its ENV vars (mostly interested in PATH). And finally, are you sure it's not some crazy SELinux / AppArmor issue?

phrohdoh commented 7 years ago

Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-105-generic x86_64)

thill@arsenic2:~$ whereis which
which: /bin/which /usr/bin/which /usr/share/man/man1/which.1.gz

thill@arsenic2:~$ whereis sox
sox: /usr/bin/sox /usr/share/man/man1/sox.1.gz

thill@arsenic2:~$ whereis mpg123
mpg123: /usr/bin/mpg123.bin /usr/bin/mpg123 /usr/share/man/man1/mpg123.1.gz

I assume the user that invokes the script is the same as the one running asterisk which in my case is the root user.

root@arsenic2:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
zaf commented 7 years ago

All looks right, quite bizarre. Try adding some print statements, or better use console_log() to see the values of $sox and $mpg123 before the test happens in line 99.

phrohdoh commented 7 years ago
<SIP/kazoo-00000007>AGI Rx << NOOP " -- googletts.agi: /usr/bin/sox
[..snip..]
<SIP/kazoo-00000007>AGI Rx << NOOP " -- googletts.agi: /usr/bin/mpg123
zaf commented 7 years ago

Looks like both variables have a value, (!$mpg123 || !$sox) is false and the script should continue to run without throwing an error that some of the dependencies are missing. Isn't this the case?

phrohdoh commented 7 years ago

Yes that is the case, sorry. Mentally I was still working on #34 here. This can be closed but the README / information should state that both sox and mpg123 are required.

janduy commented 6 years ago

@Phrohdoh

Good Morning,

Were you able to solve the flaws in your google tts?

I'm with the same problem = (

I'll put down my log:

Launched AGI Script /var/lib/asterisk/agi-bin/googletts.agi <SIP/8004-00000003>AGI Tx >> agi_request: googletts.agi <SIP/8004-00000003>AGI Tx >> agi_channel: SIP/8004-00000003 <SIP/8004-00000003>AGI Tx >> agi_language: br <SIP/8004-00000003>AGI Tx >> agi_type: SIP <SIP/8004-00000003>AGI Tx >> agi_uniqueid: 1515936324.3 <SIP/8004-00000003>AGI Tx >> agi_version: certified/13.13-cert9 <SIP/8004-00000003>AGI Tx >> agi_callerid: 8004 <SIP/8004-00000003>AGI Tx >> agi_calleridname: 8004 <SIP/8004-00000003>AGI Tx >> agi_callingpres: 0 <SIP/8004-00000003>AGI Tx >> agi_callingani2: 0 <SIP/8004-00000003>AGI Tx >> agi_callington: 0 <SIP/8004-00000003>AGI Tx >> agi_callingtns: 0 <SIP/8004-00000003>AGI Tx >> agi_dnid: 8002 <SIP/8004-00000003>AGI Tx >> agi_rdnis: unknown <SIP/8004-00000003>AGI Tx >> agi_context: ivrtime <SIP/8004-00000003>AGI Tx >> agi_extension: s <SIP/8004-00000003>AGI Tx >> agi_priority: 4 <SIP/8004-00000003>AGI Tx >> agi_enhanced: 0.0 <SIP/8004-00000003>AGI Tx >> agi_accountcode: <SIP/8004-00000003>AGI Tx >> agi_threadid: 139829338539776 <SIP/8004-00000003>AGI Tx >> agi_arg_1: Digite o seu numero de cliente assim eu posso lhe identificar <SIP/8004-00000003>AGI Tx >> agi_arg_2: pt-BR <SIP/8004-00000003>AGI Tx >> <SIP/8004-00000003>AGI Rx << NOOP " -- googletts.agi: sox or mpg123 is missing. Aborting." <SIP/8004-00000003>AGI Tx >> 200 result=0 -- <SIP/8004-00000003>AGI Script googletts.agi completed, returning 0 -- Executing [s@ivrtime:5] NoOp("SIP/8004-00000003", "..::: ENCERRANDO CHAMADA - IVRTIME ::...") in new stack -- Executing [s@ivrtime:6] Hangup("SIP/8004-00000003", "") in new stack == Spawn extension (ivrtime, s, 6) exited non-zero on 'SIP/8004-00000003'

phrohdoh commented 6 years ago

Hi @janduy, as indicated in my previous comment both sox and mpg123 are required (because of this if).

Please verify that they both are installed (and install them if not).

janduy commented 6 years ago

Hi, @Phrohdoh yes, they are installed, I checked and reinstalled both.

phrohdoh commented 6 years ago

Please provide the information I provided in previous comments.

1) values of $sox and $mpg123 in the perl script at runtime 2) $PATH of the user invoking the script 3) Where both of these executables are installed on your system

janduy commented 6 years ago

Okay, I'm not at home now. I'll send it to you at night, okay? thank you!

janduy commented 6 years ago

@Phrohdoh

Hi, below the data.

Commands: [root@bu7bu12 ~]# whereis which which: /usr/bin/which /usr/share/man/man1/which.1.gz [root@bu7bu12 ~]# whereis sox sox: /usr/bin/sox /usr/lib64/sox /usr/include/sox /usr/share/man/man1/sox.1.gz [root@bu7bu12 ~]# whereis mpg123 mpg123: /usr/bin/mpg123 /usr/local/bin/mpg123 /usr/local/lib/mpg123 /usr/src/mpg123-1.25.6/mpg123.spec [root@bu7bu12 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

I did a second test, I put the absolute paths of "SOX" and "MPG123" there is another bizarre error.

Original: my $sox = /usr/bin/which sox; my $mpg123 = /usr/bin/which mpg123;

Changed: my $sox = /usr/bin/sox; my $mpg123 = /usr/bin/mpg123;

[root@bu7bu12 ~]# perl googletts.agi /usr/bin/sox FAIL sox: Not enough input filenames specified

Can't exec "/usr/bin/mpg123": Permissão negada at /var/lib/asterisk/agi-bin/googletts.agi line 87.

I already checked the permissions, I left all "chmod 777"