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)

Aller en bas 
Lapin nain
Lapin nain

Localisation : London
Nbr de messages : 1
Carottes : 2283

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:

You can paste this directly into the TTS box in the 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:

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:

#! /usr/bin/perl

# - 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=''.$token.'/play?';
my $encodedtext = uri_escape($text);


$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:  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, 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.

Revenir en haut Aller en bas
Red Kryptonite Nabz
Red Kryptonite Nabz

Age : 53
Localisation : 77 LE MEE SUR SEINE
Nabaztag : CRISTAL77 & ANDROID V2
Nbr de messages : 10462
Carottes : 11626

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)
Revenir en haut 
Page 1 sur 1
 Sujets similaires
» SOLVED: English TTS from NabAlive (and possibly other languages)
» Nabizdead et Nabalive
» For English-speaking Nabaztag owners ;)
» Exec command
» [APPZ] : Tuto installation d'Applications (ex FDJ Résultats du Loto)

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: