Menu

$agi->swift() / Cepstral Licensing

2010-10-18
2013-04-29
  • Brian Doyle

    Brian Doyle - 2010-10-18

    I am writing an IVR script in PHPAGI and trying to use Cepstral for TTS. Though I have licensed the product, when I call $agi->swift(), before my text is "read" (during a call), the engine / voice states that the product isn't licensed. Has anyone else encountered this and know of the solution?

     
  • josephtikva

    josephtikva - 2010-10-19

    The license only allows one TTS conversion at a time.

    You should probably cache the soundfiles. I have code you can use, let me know if you need it.

     
  • Brian Doyle

    Brian Doyle - 2010-10-19

    Please provide. Thanks.

     
  • josephtikva

    josephtikva - 2010-10-19

    Add this to the phpagi class.

    function swift_file($text, $frequency = 8000, $voice = null)
        {
            if (!is_null($voice))
                $voice = "-n $voice";
            elseif (isset($this->config['cepstral']['voice']))
                $voice = "-n {$this->config['cepstral']['voice']}";
            $text = trim($text);
            if ($text == '')
                return;
                
            $hash = md5($text);
            $fname = $this->config['phpagi']['tempdir'];
            
            $fname .= 'swift_' . $hash; 
            /** first checks if file exists as a recording - i0**/
                if (!file_exists("$fname.wav")) {
                    // write text file
                    if (!file_exists("$fname.txt")) {
                        $fp = fopen("$fname.txt", 'w');
                        fputs($fp, $text);
                        fclose($fp);
                    }
                    shell_exec("{$this->config['cepstral']['swift']} -p audio/channels=1,audio/sampling-rate=$frequency $voice -o $fname.wav -f $fname.txt");
                }
            return $fname;
        }
    
     
  • josephtikva

    josephtikva - 2010-10-19

    Usage:

    This is assuming that you are mostly playing the same text, otherwise your Swift TTS engine will be overloaded.

    I try to break down the IVR into smaller pieces, and play several files as one prompt.

    I'd be happy to help, if you'd like to contact me directly.

    Let me know if this helped

    Joseph

    $agi->stream_file($agi->swift_file("THE TEXT"), $escapeKeys):
    
     
  • Brian Doyle

    Brian Doyle - 2010-10-20

    Hi Joseph,

    Thank you for the code snippet, it looks very promising - and will definitely be beneficial once the load increases.  However, I still have the issue with the "This voice is not licensed…" message being played.  I spoke with Digium support, and they advised that it is because of the way that Cepstral is being called in PHPAGI.  This didn't sound quite right (as I am pretty sure others are using PHPAGI with Cepstral) and the person on the other end of the line didn't appear to be totally familiar with AGI - so it felt like "the blind leading the blind".  Any other ideas?

     
  • josephtikva

    josephtikva - 2010-10-20

    Brianjd,

    This wouldn't hve anything to do with swift being called in the AGI.

    I would do the following, depending on the call volume, and type of prompts being converted.

    1. The simplest is to buy additional licenses from Cepstral. But that may not completely solve your problem, depending on the nember of concurrent calls using swift.
    2. Break down the prompts into several pieces, so if for example you are playing a price to a caller, that goes somthing like this:
    "The price for this item is 14 dollars and fifty cents. To purchase this item press 1"
    I would break that down to th following prompts, and loop them (I can implement this for you):
    a. Swift => "The price for this item is"
    b. Say_number => "14"
    c. Swift => "dollars"
    d. Swift => "and"
    e. say_number => "50"
    f. Swift => "cents"
    g. Swift => "to purchase this item press 1"

    If you do this you will only use swift to generate the first file once, and maybe even eliminate the need to use swift.
    I try to use swift only for the portion of the prompt that is dynamic.

    But this depends on the nature of the application you are trying to build.

    Joseph

     
  • josephtikva

    josephtikva - 2010-10-20

    Briandj,

    I should explain why you are having an issue:

    The cepstral license only allows one conversion at a time, so if two callers are in the agi, and both need TTS conversions done at the same time, you get that prompt.
    The code I provided you does a conversion, and saves the file, and the file can then be played through stream_file.  And the next time you need to play that text, you WON'T need to use swift, as the file was already converted. And exists as an audio file.
    I have system that use swift with 50-70 concurrent calls, using ONE license, and never had a problem.

    Joseph

     
  • Brian Doyle

    Brian Doyle - 2010-10-20

    Joseph,

    I understand what you are saying, and understand the nature of the issue you are describing, but currently I am the ONLY person in the AGI application.

    - b

     
  • Brian Doyle

    Brian Doyle - 2010-10-20

    I ended up resolving by purchasing a license directly from Cepstral which applied globally (ie. doesn't matter the execution environment), it seems there was an issue with the one I purchased from Digium. 

    - b

     
  • Brian Doyle

    Brian Doyle - 2010-10-20

    Thank you for your help Joseph!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.