-1

I'm just trying to run demo in PHPAGI folder available here: https://sourceforge.net/projects/phpagi/files/phpagi/2.20/

However, the text2wav is not working. When the script has to run text2wav (in dtmf.php for example), this error show:

    0x7ff7b000bf30 -- Strict RTP switching to RTP target address 192.168.37.36:4010 as source
<SIP/phone1-00000005>AGI Rx << ANSWER
<SIP/phone1-00000005>AGI Tx >> 200 result=0
<SIP/phone1-00000005>AGI Rx << STREAM FILE /var/spool/asterisk//tmp//text2wav_ace75969fc9b3a79aef4da4291ca0646 "" 0
[Jul  6 11:19:20] WARNING[4081][C-00000006]: file.c:824 ast_openstream_full: File /var/spool/asterisk//tmp//text2wav_ace75969fc9b3a79aef4da4291ca0646 does not exist in any format
<SIP/phone1-00000005>AGI Tx >> 200 result=-1 endpos=0
<SIP/phone1-00000005>AGI Rx << STREAM FILE /var/spool/asterisk//tmp//text2wav_2ad655609cb6a3f021452a1bd8fa7b1a "" 0

I tried a lot of things: giving permission for every file, trying to understang text2wav source code (https://phpagi.sourceforge.net/phpagi22/api-docs/__filesource/fsource_phpAGI__phpagi.php.html#a1331), I put the max verbosity in asterisk console and activated agi debug on but still can't understnand what's happening. the fact is, the file in /var/spool/asterisk//tmp//text2wav_f87b365372c500c76e497087ac7e470a do exist in txt format but not in wav

Edit: Here's the code that does not work:

#!/usr/bin/php -q
<?php
  set_time_limit(30);
  require('phpagi.php');
  error_reporting(E_ALL);

  $agi = new AGI();
  $agi->answer();

  $cid = $agi->parse_callerid();
  $agi->text2wav("Hello, {$cid['name']}.");
  do
  {
    $agi->text2wav('Enter some numbers and then press the pound key. Press 1 1 1 followed by the pound key to quit.');
    $result = $agi->get_data('beep', 3000, 20);
    $keys = $result['result'];
    $agi->text2wav("You entered $keys");
  } while($keys != '111');
  $agi->text2wav('Goodbye');
  $agi->hangup();
?>

My dialplan :

exten => 42,1,Answer
exten => 42,2,agi(dtmf.php)
exten => 42,3,Hangup
Florian
  • 1
  • 3
  • Please share more details, like the code invovled and your attempts to resolve the problem – Nico Haase Jul 06 '23 at 09:53
  • I edited my post. As I said, i tried to change permission to solve but doesnt work at all. After reading the source code text2wav, I still don't get it. – Florian Jul 06 '23 at 12:07
  • The code you've linked to clearly runs `shell_exec("{$this->config['festival']['text2wave']} -F $frequency -o $fname.wav $fname.txt");` You have not configured this value in the code given. Do you even have [Festival](https://www.cstr.ed.ac.uk/projects/festival/) installed? That would be step 1 – miken32 Jul 06 '23 at 19:02
  • As long as I'm using PHPAGI, Festival should be install with the package. I mean this code is the source code of the PHPAGI that should work without any addiotional install. – Florian Jul 07 '23 at 09:56

2 Answers2

0
  1. stop asterisk service

  2. run asterisk from ssh console via

    asterisk -vvvvgc

  3. check error. Now will be on console, when running service it go... somewhere. In most cases to /dev/tt9

Most likely cases are

  1. path incorrect
  2. asterisk have no permission to text2wave or folder where file to be stored.
  3. no text2wave
arheops
  • 15,544
  • 1
  • 21
  • 27
  • Thanks for your response. After runing asterisk -vvvvgc i got a lot of loading things and some error: [Jul 7 11:50:45] ERROR[10024]: loader.c:2534 load_modules: res_pjsip_publish_asterisk declined to load. [Jul 7 11:50:45] ERROR[10024]: loader.c:2534 load_modules: cel_sqlite3_custom declined to load. [Jul 7 11:50:45] ERROR[10024]: loader.c:2534 load_modules: cdr_sqlite3_custom declined to load. But the matter is that my sip phone does not connect to asterisk anymore. I load module chan_sip.so but still not working. I dont know why. – Florian Jul 07 '23 at 09:59
  • Maybe selinux enabled on system. Should be no difference. Warning at start is not your error. Need make call and see – arheops Jul 07 '23 at 14:26
-1

Your message error is telling you that the can not found the path it tries to use

<SIP/phone1-00000005>AGI Rx << STREAM FILE /var/spool/asterisk//tmp//text2wav_ace75969fc9b3a79aef4da4291ca0646 "" 0

Asterisk use the path /var/spool/asterisk as part of the configuration, so when you try to play an audio using text2wav, this is taken that path to create the wav and play.

You need to have the path /var/spool/asterisk/tmp. To create it, execute at linux shell

mkdir -p /var/spool/asterisk/tmp

Be aware that you must change permission to that new directory to be use be asterisk process

chow -R asterisk:asterisk /var/spool/asterisk/tmp

if the asterisk process is running with asterisk user.

Hope this can help you.

Saul Uribe
  • 744
  • 4
  • 10
  • Thank for the details of your response! The folder /var/spool/asterisk/tmp already exist and i gave him all permission. However, when i tried to 'chow -R asterisk:asterisk /var/spool/asterisk/tmp' i get an "invalid user ' error. So I looked for what user using asterisk ( with the command ps -ef ) and found this : 'root 9038 9031 0 11:06 pts/2 00:00:00 rasterisk rcvvvvvvvvvvvvvvvv' Wich mean root is the user I guess. So I desperately ran the command 'chow -R root:root /var/spool/asterisk/tmp' but it doesnt worked. – Florian Jul 07 '23 at 09:48
  • Understood, first check if wav files has been created at path (```/var/spool/asterisk/tmp```), second check if you have selinux active, edit file ```/etc/selinux/config``` and set it disabled and thirth check if you have installed ```festival``` application. If you disabled selinux, you must restart linux to apply changes or execute ```setenforce 0``` at linux shell – Saul Uribe Jul 07 '23 at 19:42