zaf / asterisk-googletts

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

Entire call (5 seconds) is silent then disconnects #34

Closed phrohdoh closed 7 years ago

phrohdoh commented 7 years ago

The output says that /tmp/9c45b949ba1c0594e69d73586c34c386.slin is being played but I hear no audio.

exten => s,1,Answer()
 same =>    n,agi(googletts.agi,"This is a simple google text to speech test in english.",en)
    -- Attempting call on SIP/kazoo/1972XXXXXXX for s@kazoo-test-taryn:1 (Retry 1)
  == Using SIP RTP CoS mark 5
    -- Called kazoo/1972XXXXXXX
    -- SIP/kazoo-0000000a is ringing
    -- SIP/kazoo-0000000a is making progress
    -- SIP/kazoo-0000000a answered
    -- Executing [s@kazoo-test-taryn:1] Answer("SIP/kazoo-0000000a", "") in new stack
    -- Executing [s@kazoo-test-taryn:2] AGI("SIP/kazoo-0000000a", "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
    -- <SIP/kazoo-0000000a> Playing '/tmp/9c45b949ba1c0594e69d73586c34c386.slin' (escape_digits=) (sample_offset 0) (language 'en')
    -- <SIP/kazoo-0000000a>AGI Script googletts.agi completed, returning 0
    -- Auto fallthrough, channel 'SIP/kazoo-0000000a' status is 'UNKNOWN'
root@arsenic2:# file /tmp/9c45b949ba1c0594e69d73586c34c386.slin
/tmp/9c45b949ba1c0594e69d73586c34c386.slin: ERROR: cannot open `/tmp/9c45b949ba1c0594e69d73586c34c386.slin' (No such file or directory)
zaf commented 7 years ago

Please enable the scripts debug mode by setting $debug = 1 in the 'User defined parameters' exction at the top of the script. Also have a look at my comments for issue #33

phrohdoh commented 7 years ago

5 seconds of silence:

    -- Attempting call on SIP/kazoo/1972XXXXXXX for s@kazoo-test-taryn:1 (Retry 1)
  == Using SIP RTP CoS mark 5
    -- Called kazoo/1972XXXXXXX
    -- SIP/kazoo-00000004 is ringing
    -- SIP/kazoo-00000004 is making progress
    -- SIP/kazoo-00000004 answered
    -- 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
<SIP/kazoo-00000004>AGI Tx >> agi_request: googletts.agi
<SIP/kazoo-00000004>AGI Tx >> agi_channel: SIP/kazoo-00000004
<SIP/kazoo-00000004>AGI Tx >> agi_language: en
<SIP/kazoo-00000004>AGI Tx >> agi_type: SIP
<SIP/kazoo-00000004>AGI Tx >> agi_uniqueid: 1482954710.8
<SIP/kazoo-00000004>AGI Tx >> agi_version: 13.13.0
<SIP/kazoo-00000004>AGI Tx >> agi_callerid: 972XXXXXXX
<SIP/kazoo-00000004>AGI Tx >> agi_calleridname: 1972XXXXXXX
<SIP/kazoo-00000004>AGI Tx >> agi_callingpres: 0
<SIP/kazoo-00000004>AGI Tx >> agi_callingani2: 0
<SIP/kazoo-00000004>AGI Tx >> agi_callington: 0
<SIP/kazoo-00000004>AGI Tx >> agi_callingtns: 0
<SIP/kazoo-00000004>AGI Tx >> agi_dnid: unknown
<SIP/kazoo-00000004>AGI Tx >> agi_rdnis: unknown
<SIP/kazoo-00000004>AGI Tx >> agi_context: kazoo-test-taryn
<SIP/kazoo-00000004>AGI Tx >> agi_extension: s
<SIP/kazoo-00000004>AGI Tx >> agi_priority: 2
<SIP/kazoo-00000004>AGI Tx >> agi_enhanced: 0.0
<SIP/kazoo-00000004>AGI Tx >> agi_accountcode:
<SIP/kazoo-00000004>AGI Tx >> agi_threadid: 139668928726784
<SIP/kazoo-00000004>AGI Tx >> agi_arg_1: This is a simple google text to speech test in english.
<SIP/kazoo-00000004>AGI Tx >> agi_arg_2: en
<SIP/kazoo-00000004>AGI Tx >>
<SIP/kazoo-00000004>AGI Rx << CHANNEL STATUS
<SIP/kazoo-00000004>AGI Tx >> 200 result=6
<SIP/kazoo-00000004>AGI Rx << GET FULL VARIABLE ${CHANNEL(audionativeformat)}
<SIP/kazoo-00000004>AGI Tx >> 200 result=1 ((ulaw))
<SIP/kazoo-00000004>AGI Rx << NOOP " -- googletts.agi: Text passed for synthesis: This is a simple google text to speech test in english."
<SIP/kazoo-00000004>AGI Tx >> 200 result=0
<SIP/kazoo-00000004>AGI Rx << NOOP " -- googletts.agi: Language: en, Interrupt keys: , Sample rate: 8000"
<SIP/kazoo-00000004>AGI Tx >> 200 result=0
<SIP/kazoo-00000004>AGI Rx << NOOP " -- googletts.agi: Speed: 1, Caching: 1, Cache dir: /tmp"
<SIP/kazoo-00000004>AGI Tx >> 200 result=0
<SIP/kazoo-00000004>AGI Rx << NOOP " -- googletts.agi: File already in cache."
<SIP/kazoo-00000004>AGI Tx >> 200 result=0
<SIP/kazoo-00000004>AGI Rx << STREAM FILE /tmp/9c45b949ba1c0594e69d73586c34c386 ""
    -- <SIP/kazoo-00000004> Playing '/tmp/9c45b949ba1c0594e69d73586c34c386.slin' (escape_digits=) (sample_offset 0) (language 'en')
<SIP/kazoo-00000004>AGI Tx >> 200 result=0 endpos=30720
    -- <SIP/kazoo-00000004>AGI Script googletts.agi completed, returning 0
    -- Auto fallthrough, channel 'SIP/kazoo-00000004' status is 'UNKNOWN'
[Dec 28 13:52:02] NOTICE[59086]: pbx_spool.c:426 attempt_thread: Call completed to SIP/kazoo/1972XXXXXXX
phrohdoh commented 7 years ago

For what it is worth:

root@arsenic2:~# ls -Fla /tmp
total 80
drwxrwxrwt  4 root root  4096 Dec 28 13:24 ./
drwxr-xr-x 22 root root  4096 Dec 20 06:49 ../
-rw-------  1 root root  1273 Dec 22 11:17 7ycp6uL4UP
-rw-r--r--  1 root root 61440 Dec 22 11:29 9c45b949ba1c0594e69d73586c34c386.sln
drwx------  2 root root  4096 Dec 22 11:05 EgzUQ1wo9C/
drwx------  2 root root  4096 Dec 22 11:02 ls_vqn6C9J/
zaf commented 7 years ago

Try playing the cached file with sox to see if it contains any sound data:

play -t raw -r 8000 -e signed -b 16 -c 1 /tmp/9c45b949ba1c0594e69d73586c34c386.sln

If you hear any speech then the problem is somewhere within your asterisk setup not the TTS script itself. If nothing plays back then delete the cached file and try running the test again. Make a few changes to the script to keep all the temporary and intermediate files in order to check them and see in which step the data gets lost.

Change line 200 to: ($fh, $tmpname) = tempfile("ggl_XXXXXXXX", DIR => $tmpdir, UNLINK => 0);

Commend out lines 229: unlink "$tmpname.wav";

and 371: unlink glob "$tmpname*";

Run the test again. In your temp folder you will find an mp3 file with the data we got from Google. A wav file that is the decoded data we get after running mpg123, and finally the sln file that is the raw LPCM we get after running sox and it's the data we use in asterisk. Try playing back all of them and see if they contain any sound.

phrohdoh commented 7 years ago

This isn't a machine I have direct access to so I can't listen directly to any audio output. I'll talk with the project's sysadmin and see what we can do then I'll give this a try, thank you!

zaf commented 7 years ago

You can probably scp the files in a local machine and test them there.

phrohdoh commented 7 years ago

Oh, of course. It is very late here, please forgive the ignorance.