[Freeswitch-users] TTS module using SAPI?

Nathan Neulinger nneul at mst.edu
Fri May 27 18:46:12 MSD 2016


I've been using this with the Translate service in Azure for TTS. It would probably be trivial to adapt that kind of 
client script to calling some service on IIS that uses SAPI.

Here's a snippet from the script I use if you wanted to adapt it for your purposes... rest of script just has some local 
calling conventions and wrapping for caching the results as well as feeding it through a couple filters from sox utility 
to strip off leading/trailing silence.

     #
     # First get token
     #
     my $ua = new LWP::UserAgent;
     my $req = HTTP::Request->new( POST => "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13" );
     $req->content_type("application/x-www-form-urlencoded");
     my @args = (
         "grant_type"    => "client_credentials",
         "client_id"     => $msapp,
         "client_secret" => $msappkey,
         "scope"         => "http://api.microsofttranslator.com"
     );
     my @reqcontent = ();
     while (@args) {
         my $key = shift(@args);
         my $val = &Encode_URLEncode( shift(@args) );
         push( @reqcontent, "$key=$val" );
     }
     $req->content( join( "&", @reqcontent ) );

     my $res         = $ua->request($req);
     my $respcontent = $res->content;

     my $token;
     eval {
         my $data = decode_json($respcontent);
         $token = $data->{access_token};
     };

     my $options = "MaxQuality";
     if ( $gender =~ m/^f/io ) {
         $options .= "|female";
     }
     else {
         $options .= "|male";
     }

     my @args = (
         "language" => "en",
         "format"   => "audio/wav",
         "options"  => $options,
         "appid"    => "",
         "text"     => $text
     );
     my @reqcontent = ();
     while (@args) {
         my $key = shift(@args);
         my $val = &Encode_URLEncode( shift(@args) );
         push( @reqcontent, "$key=$val" );
     }
     $req = HTTP::Request->new(
         GET => "https://api.microsofttranslator.com/V2/Http.svc/Speak?" . join( "&", @reqcontent ) );
     $req->header( "Authorization" => "bearer $token" );

     my $res = $ua->request($req);
     $content = $res->content;

     unlink($cachefile);
     unlink($cacheorig);

     if ( !$res->is_success ) {
         print "Failed API operation against microsoft TTS.\n";
         exit(1);
     }

     open( my $out, ">$cacheorig" );
     print $out $content;
     close($out);




-- Nathan

On 05/27/2016 09:35 AM, Abaci B wrote:
> If there is a command line tool that can utilize Microsoft's TTS engine, then you can use mod_tts_commandline
> <https://wiki.freeswitch.org/wiki/Mod_tts_commandline>
>
> On Fri, May 27, 2016 at 9:49 AM, Alex Pierry <alex at teclan.com.br <mailto:alex at teclan.com.br>> wrote:
>
>     Hi All,
>
>     what about a Freeswitch module that integrates with a TTS engine through SAPI enviroment?
>     Do you know if exists some initiative in this way?
>     It would be great to use Microsoft's TTS engine that has a good quality and a large number of languages available.
>
>     Thanks,
>     Alex.
>
>
>
>     */
>     *
>
>
>     *
>     <http://pt.slideshare.net/marketingteclan>
>     /*
>
>     <http://blog.teclan.com.br/>
>
>
>     _________________________________________________________________________
>     Professional FreeSWITCH Consulting Services:
>     consulting at freeswitch.org <mailto:consulting at freeswitch.org>
>     http://www.freeswitchsolutions.com
>
>     Official FreeSWITCH Sites
>     http://www.freeswitch.org
>     http://confluence.freeswitch.org
>     http://www.cluecon.com
>
>     FreeSWITCH-users mailing list
>     FreeSWITCH-users at lists.freeswitch.org <mailto:FreeSWITCH-users at lists.freeswitch.org>
>     http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>     UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>     http://www.freeswitch.org
>
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>

-- 
------------------------------------------------------------
Nathan Neulinger                       nneul at mst.edu
Missouri S&T Information Technology    (573) 612-1412
System Administrator - Architect



Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list