Forum des Objets Communicants et Solutions pour les Libérer...


 
AccueilAccueil  GalerieGalerie  FAQFAQ  RechercherRechercher  S'enregistrerS'enregistrer  Connexion  

Partagez | 
 

 SOLVED: English TTS from NabAlive (and possibly other languages)

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
gjd
Lapin nain
Lapin nain


Localisation : London
Nbr de messages : 1
Carottes : 1824

MessageSujet: SOLVED: English TTS from NabAlive (and possibly other languages)   Jeu 20 Déc 2012 - 19:29

Up until the Violet platform was switched off, we were using our Nabaztag to read out alarms from our Nagios monitoring system. Since NabAlive came about I've been looking to set this back up again, but only having French TTS was causing our English status messages to be somewhat unintelligable.

I decided to have another look at this as we've got a platform change freeze at the moment, and it's much easier to do than I was expecting. It turns out Google Translate has a text to speech facility where you can send it a string and it returns an MP3, here's an example:

http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=Hello+World

You can paste this directly into the TTS box in the nabaztag.com actions interface, and the MP3 returned is read out by your Nabaztag.

But if you want to script this, pasting into a browser isn't much use, so here is what happens behind the scenes when you submit the URL:

http://www.nabaztag.com/nabaztags/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/play?url=http%3A%2F%2Ftranslate.google.com%2Ftranslate_tts%3Fie%3DUTF-8%26tl%3Den%26q%3Dhello%2Bworld

where xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is the API key for your rabbit.

This lead on to me putting together a quick script in Perl to do the encoding and post the request for me:

Code:
#! /usr/bin/perl

# send_nabaztag_tts.pl - Provides English Text to speech for your Nabaztag on the NabAlive platform via Google Translate
# (C)2012 Gareth Davis - No rights reserved - This script is freely distributable

use LWP;
use HTTP::Request::Common;
use URI::Escape;

my $browser = LWP::UserAgent->new;

if  ( @ARGV[0] eq "" || @ARGV[1] eq "" )
{
    die "USAGE: $0 Token Message\n";
}


my $token = @ARGV[0];
my $text = @ARGV[1];

my $baseurl='http://www.nabaztag.com/nabaztags/'.$token.'/play?url=http%3A%2F%2Ftranslate.google.com%2Ftranslate_tts%3Fie%3DUTF-8%26tl%3Den%26q%3D';
my $encodedtext = uri_escape($text);

$encodedtext=~s/%20/%2B/gi;

$url = $baseurl.$encodedtext;
print "Requesting $url\n";
my $response = $browser->get( $url );

if (!$response->is_success) {
        print "FAIL: ".$response->content;
}

You then call the Perl script with:
Code:
send_nabaztag_tts.pl  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx "Hello World"
I worked this out by sniffing the web transactions going backwards and forward between the web browser and nabaztag.com, so this probably isn't officially supported. I did try using the official API, but kept getting Error 500 messages for reasons I didn't understand.

Although the Google Translate TTS API is in beta, it supports a number of languages other than English. You would need to play with the tl=en perameter in the URL to switch to another language.

Enjoy!
Revenir en haut Aller en bas
jpp77350
Red Kryptonite Nabz
Red Kryptonite Nabz
avatar

Age : 52
Localisation : 77 LE MEE SUR SEINE
Nabaztag : CRISTAL77 & ANDROID V2
Nbr de messages : 10200
Carottes : 11088

MessageSujet: Re: SOLVED: English TTS from NabAlive (and possibly other languages)   Jeu 20 Déc 2012 - 21:10

thank's anyway for the job and investigations!
All the tips & tricks, to keep alive and go on, our beloved rabitt's are welcome!

_____________________________


 


La haine prospère sur la lâcheté

On n'arrête pas de jouer parce qu'on vieillit,
on vieillit, parce qu'on arrête de jouer!
De la Rochefoucauld
...  Soyons Joueurs!
Revenir en haut Aller en bas
 
SOLVED: English TTS from NabAlive (and possibly other languages)
Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» SOLVED: English TTS from NabAlive (and possibly other languages)
» le nabaztag speak english ou pas ... ???
» Good english / german news radio for podcast
» Unofficial English forums - All english all the time :-)
» English-Model of presentation

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Forum des Objets Communicants et Solutions pour les Libérer... :: IV. I Don't Speak French! :: NabAlive, the New Official server for your Nabaztag:tags-
Sauter vers: