Re: [Freeswitch-dev] Cepstral locks up
Hi, I am happy to, although I'm sure it can be improved as this is my first lua script. Although its in production now and working like a charm. :) First, I created a phrase macro for requesting TTS, and then call the LUA script from there: <!--Provides a phase to speak custom text--> <macro name="tts"> <input pattern="(.*)"> <match> <action function="execute" data="lua(tts_cache.lua '$1')"/> <action function="play-file" data="${tts_file}" /> </match> </input> </macro> Then this is the tts_cache.lua script: -- This script generates a wav file of the sentence passed in to it. -- It uses the Cepstral swift command to perform text-to-speech conversion. -- If the wav file already exists for this sentence, then it is not generated. -- Author: Thomas Parrott <thomas.parrott@infinity-tracking.com> api = freeswitch.API(); msg = argv[1]; msgMd5 = api:execute( "md5", msg ); filename = '/var/lib/tts_cache/' .. msgMd5 .. '.wav'; cmd = '/opt/swift/bin/swift'; -- Set a channel variable so that we know which file to play back. session:setVariable( 'tts_file', filename ); -- Check whether the file already exists. file, errMsg = io.open( filename, "r" ) if not file then api:execute( 'system', cmd .. ' -o "' .. filename .. '" "' .. msg .. '"' ); end If I can have a branch into contrib I'll post it up there. Thanks Tom
On 11/11/2011 01:00 AM, Tom Parrott wrote: [snip]
Let me know if you would like to see the script.
Good to see you found a solution. If you don't mind sharing your script with the Community perhaps you could ask one of the developers to put it somewhere in contrib/ or give you access to your own branch in contrib/.
Regards, Patrick
Just throw this up on the wiki on the mod_cepstral page. -MC On Fri, Nov 11, 2011 at 9:10 AM, Tom Parrott <tomp@tomp.co.uk> wrote:
Hi,
I am happy to, although I'm sure it can be improved as this is my first lua script. Although its in production now and working like a charm. :)
First, I created a phrase macro for requesting TTS, and then call the LUA script from there:
<!--Provides a phase to speak custom text--> <macro name="tts"> <input pattern="(.*)"> <match> <action function="execute" data="lua(tts_cache.lua '$1')"/> <action function="play-file" data="${tts_file}" /> </match> </input> </macro>
Then this is the tts_cache.lua script:
-- This script generates a wav file of the sentence passed in to it. -- It uses the Cepstral swift command to perform text-to-speech conversion. -- If the wav file already exists for this sentence, then it is not generated. -- Author: Thomas Parrott <thomas.parrott@infinity-tracking.com> api = freeswitch.API(); msg = argv[1]; msgMd5 = api:execute( "md5", msg ); filename = '/var/lib/tts_cache/' .. msgMd5 .. '.wav'; cmd = '/opt/swift/bin/swift';
-- Set a channel variable so that we know which file to play back. session:setVariable( 'tts_file', filename );
-- Check whether the file already exists. file, errMsg = io.open( filename, "r" ) if not file then api:execute( 'system', cmd .. ' -o "' .. filename .. '" "' .. msg .. '"' ); end
If I can have a branch into contrib I'll post it up there.
Thanks Tom
On 11/11/2011 01:00 AM, Tom Parrott wrote: [snip]
Let me know if you would like to see the script.
Good to see you found a solution. If you don't mind sharing your script with the Community perhaps you could ask one of the developers to put it somewhere in contrib/ or give you access to your own branch in contrib/.
Regards, Patrick
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
participants (2)
-
Michael Collins
-
Tom Parrott