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