[tuxdroid-svn] r5332 - in software_suite_v3/smart-core/smart-api/csharp/trunk: API ControlTuxDroid
Status: Beta
Brought to you by:
ks156
|
From: JDM <c2m...@c2...> - 2009-09-07 18:54:33
|
Author: JDM
Date: 2009-09-07 20:54:16 +0200 (Mon, 07 Sep 2009)
New Revision: 5332
Modified:
software_suite_v3/smart-core/smart-api/csharp/trunk/API/TuxAPI.cs
software_suite_v3/smart-core/smart-api/csharp/trunk/ControlTuxDroid/TuxAPIDemo/Form1.cs
Log:
* Fixed Speak() function now it work with TuxBox
* Fixed ControlTuxDroid for use the new Speak() function from the API
Modified: software_suite_v3/smart-core/smart-api/csharp/trunk/API/TuxAPI.cs
===================================================================
--- software_suite_v3/smart-core/smart-api/csharp/trunk/API/TuxAPI.cs 2009-09-04 11:45:26 UTC (rev 5331)
+++ software_suite_v3/smart-core/smart-api/csharp/trunk/API/TuxAPI.cs 2009-09-07 18:54:16 UTC (rev 5332)
@@ -85,6 +85,13 @@
namespace TuxAPI
{
+ public class TuxAPI_Locutor
+ {
+ public static readonly string Ryan = "Ryan";
+ public static readonly string Heather = "Heather";
+ public static readonly string Graham = "Graham";
+ }
+
public class TuxAPI
{
#region ENUMERATIONS
@@ -132,15 +139,6 @@
}
/// <summary>
- /// The TTS voice (TODO: Add others voices)
- /// </summary>
- public enum TuxAPI_SPEAK_LOCUTOR : byte
- {
- Bruno = 0,
- Julie = 1,
- }
-
- /// <summary>
/// 3 levels of luminosity intensity i've defined (value to check and modify !!)
/// </summary>
public enum TuxAPI_LEDS_INTENSITY_LEVEL
@@ -495,102 +493,21 @@
#endregion
#region TTS SPEECH CONTROL
- /// <summary>
- /// Allow to use the TTS Speech
- /// </summary>
- /// <param name="level">Access Level</param>
- /// <param name="Text">Text to read</param>
- private static void DoSpeak(TuxAPI_LEVEL level, string Text)
- {
- wc = new WebClient();
- string final_uri = string.Empty;
- //http://localhost:270/0/flippers/up?0 //permet de faire mettre les ailles en haut !
-
- final_uri = "http://" + TuxAPI_Host + ":" + TuxAPI_Port + "/" + (int)level + "/tts/speak?text=" + Text;
-
- wc.DownloadString(final_uri);
- }
-
/// <summary>
- /// Allow to use the TTS Speech with locutor choose
+ /// Allow to use the TTS Speach
/// </summary>
/// <param name="level">Access Level</param>
- /// <param name="locutor">Locutor from enum</param>
/// <param name="Text">Text to read</param>
- private static void DoSpeak(TuxAPI_LEVEL level, TuxAPI_SPEAK_LOCUTOR locutor, string Text)
- {
- wc = new WebClient();
- string start_uri = string.Empty;
- string final_url = string.Empty;
-
- start_uri = "http://" + TuxAPI_Host + ":" + TuxAPI_Port + "/" + (int)level + "/tts/";
-
- //1 - locutor choice
- //http://127.0.0.1:270/0/tts/locutor?name=Bruno
- final_url = start_uri + "locutor?name=" + (byte)locutor;
- wc.DownloadString(final_url);
-
- //2 - the text
- final_url = start_uri + "speak?text=" + Text;
-
- wc.DownloadString(final_url);
- }
-
- /// <summary>
- /// Allow to use the TTS Speech with pitch modification
- /// </summary>
- /// <param name="level">Access Level</param>
- /// <param name="pitch">pitch value 50 to 200</param>
- /// <param name="Text">Text to read</param>
- private static void DoSpeak(TuxAPI_LEVEL level, int pitch, string Text)
- {
- wc = new WebClient();
- string start_uri = string.Empty;
- string final_url = string.Empty;
-
- start_uri = "http://" + TuxAPI_Host + ":" + TuxAPI_Port + "/" + (int)level + "/tts/";
-
- //1 - pitch
- //http://127.0.0.1:270/0/tts/pitch?value=10
- final_url = start_uri + "pitch?value=" + pitch;
- wc.DownloadString(final_url);
-
- //2 - text
- final_url = start_uri + "speak?text=" + Text;
-
- wc.DownloadString(final_url);
- }
-
- /// <summary>
- /// Allow to use the TTS Speech with locutor choosse and pitch modification
- /// </summary>
- /// <param name="level">Access Level</param>
/// <param name="locutor">Locutor from enum</param>
- /// <param name="pitch">pitch value 50 to 200</param>
- /// <param name="Text">Text to read</param>
- private static void DoSpeak(TuxAPI_LEVEL level, TuxAPI_SPEAK_LOCUTOR locutor, int pitch, string Text)
+ /// <param name="pitch">Pitch value 50 to 200 (100=normal)</param>
+ private static void DoSpeak(TuxAPI_LEVEL level, string Text, string locutor, int pitch)
{
wc = new WebClient();
- string start_uri = string.Empty;
- string final_url = string.Empty;
+ string final_uri = "http://" + TuxAPI_Host + ":" + TuxAPI_Port + "/" + (int)level + "/tts/speak?text=" + Text + "&locutor=" + locutor + "&pitch=" + pitch;
+ http://127.0.0.1:270/0/tts/speak?text=test&locutor=Ryan&pitch=100
+ wc.DownloadString(final_uri);
- start_uri = "http://" + TuxAPI_Host + ":" + TuxAPI_Port + "/" + (int)level + "/tts/";
-
- //1 - l'interlocuteur
- //http://127.0.0.1:270/0/tts/locutor?name=Bruno
- final_url = start_uri + "locutor?name=" + (byte)locutor;
- wc.DownloadString(final_url);
-
- //2 - Le pitch
- //http://127.0.0.1:270/0/tts/pitch?value=10
- final_url = start_uri + "pitch?value=" + pitch;
- wc.DownloadString(final_url);
-
- //3 - le texte
- final_url = start_uri + "speak?text=" + Text;
-
- wc.DownloadString(final_url);
}
#endregion
@@ -677,21 +594,21 @@
#region TTS Speak
public static void Speak(string Text)
{
- DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, Text);
+ DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, Text, TuxAPI_Locutor.Ryan,100);
}
- public static void Speak(TuxAPI_SPEAK_LOCUTOR locutor, string Text)
+ public static void Speak(string locutor, string Text)
{
- DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, locutor, Text);
+ DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, Text, locutor, 100);
}
public static void Speak(int pitch, string Text)
{
- DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, pitch, Text);
+ DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, Text, TuxAPI_Locutor.Ryan, pitch);
}
- public static void Speak(TuxAPI_SPEAK_LOCUTOR locutor, int pitch, string Text)
+ public static void Speak(string locutor, int pitch, string Text)
{
- DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, locutor, pitch, Text);
+ DoSpeak(TuxAPI_LEVEL.CLIENT_LEVEL_FREE, Text, locutor, pitch);
}
#endregion
Modified: software_suite_v3/smart-core/smart-api/csharp/trunk/ControlTuxDroid/TuxAPIDemo/Form1.cs
===================================================================
--- software_suite_v3/smart-core/smart-api/csharp/trunk/ControlTuxDroid/TuxAPIDemo/Form1.cs 2009-09-04 11:45:26 UTC (rev 5331)
+++ software_suite_v3/smart-core/smart-api/csharp/trunk/ControlTuxDroid/TuxAPIDemo/Form1.cs 2009-09-07 18:54:16 UTC (rev 5332)
@@ -6,9 +6,9 @@
using System.Threading; //sleep
using System.IO; //
using System.Xml;
+using System.Xml.Linq;
using System.Net;
-
namespace TuxAPIDemo
{
using TuxAPI;
@@ -40,7 +40,7 @@
void TimeEventMgr_OnHourChange(object sender, TuxDateTimeEventArgs e)
{
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 100, "Il est " + DateTime.Now.Hour.ToString() + " heure et " + DateTime.Now.Minute.ToString() + " minutes");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 100, "Il est " + DateTime.Now.Hour.ToString() + " heure et " + DateTime.Now.Minute.ToString() + " minutes");
}
void buttonEvent_OnHeadButtonPressed(object sender, TuxButtonEventArgs e)
@@ -48,7 +48,7 @@
if (e.buttonPressed)
{
//MessageBox.Show("MA TETE !");
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 180, "Aille !");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 180, "Aille !");
}
}
@@ -57,7 +57,7 @@
if (e.buttonPressed)
{
//MessageBox.Show("Mon aille gauche !");
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 180, "Lache mon aile gauche !");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 180, "Lache mon aile gauche !");
}
}
@@ -66,7 +66,7 @@
if (e.buttonPressed)
{
//MessageBox.Show("Mon aile droite !");
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 180, "Lache mon aile droite !");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 180, "Lache mon aile droite !");
}
}
@@ -94,7 +94,7 @@
private void button5_Click(object sender, EventArgs e)
{
//TuxAPI.Speak("Bonjour");
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 100, "Bonjour"); //un petit test (qui fonctionne ^^)
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 100, "Bonjour"); //un petit test (qui fonctionne ^^)
}
private void button6_Click(object sender, EventArgs e)
@@ -263,7 +263,7 @@
double[] li_values = new double[4];
//Tux say to his master what he doing
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 100, "Je recherche le coin le plus lumineux");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 100, "Je recherche le coin le plus lumineux");
Thread.Sleep(1000);
li_values[0] = double.Parse(TuxAPI.getStatus(TuxAPI.TuxAPI_STATUS_REQUESTED.light_level).Replace(".", ","));
@@ -310,15 +310,15 @@
TuxAPI.Rotation_Left(1);
//saying to his master this is the most high level of luminosity
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 100, "Je pense que ce coin est le plus lumineux");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 100, "Je pense que ce coin est le plus lumineux");
}
private void button36_Click(object sender, EventArgs e)
{
if (int.Parse(DateTime.Now.Minute.ToString()) > 0)
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 120, "Il est " + DateTime.Now.Hour.ToString() + " heure et " + DateTime.Now.Minute.ToString() + " minutes");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 120, "Il est " + DateTime.Now.Hour.ToString() + " heure et " + DateTime.Now.Minute.ToString() + " minutes");
else
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 120, "Il est " + DateTime.Now.Hour.ToString() + " heure");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 120, "Il est " + DateTime.Now.Hour.ToString() + " heure");
}
private void button37_Click(object sender, EventArgs e)
@@ -353,7 +353,7 @@
break;
}
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 120, "Nous somme le " + DateTime.Now.Day.ToString() + " " + mois);
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 120, "Nous somme le " + DateTime.Now.Day.ToString() + " " + mois);
}
private void button38_Click(object sender, EventArgs e)
@@ -364,7 +364,7 @@
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com/ig/api?hl=fr&weather=paris");
webRequest.ReadWriteTimeout = 1000 * 60;
-
+
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
Stream webStream = webResponse.GetResponseStream();
StreamReader webStreamReader = new StreamReader(webStream, System.Text.Encoding.Default);
@@ -374,13 +374,12 @@
XmlNode cnode = xmlWeather["xml_api_reply"]["weather"]["current_conditions"];
string condition = cnode["condition"].Attributes["data"].Value.ToString();
- string humidity = cnode["humidity"].Attributes["data"].Value.ToString().Replace("Humidité : ", ""); //
+ string humidity = cnode["humidity"].Attributes["data"].Value.ToString().Replace("Humidité : ",""); //
string temp_c = cnode["temp_c"].Attributes["data"].Value.ToString();
string temp_f = cnode["temp_f"].Attributes["data"].Value.ToString();
string vent = cnode["wind_condition"].Attributes["data"].Value.ToString();
- //La météo actuel a Paris est: " condition " avec une température de " " dégrès celcus. Le taux d'humidité est de " " pour cent
- TuxAPI.Speak(TuxAPI.TuxAPI_SPEAK_LOCUTOR.Bruno, 180, "La météo actuel à Paris est \"" + condition + "\" avec une température de " + temp_c + " degrés celcius; Le taux d'humidité est de " + humidity + " %.");
+ TuxAPI.Speak(TuxAPI_Locutor.Ryan, 180, "La météo actuel à Paris est \"" + condition + "\" avec une température de " + temp_c + " degrés celcius; Le taux d'humidité est de " + humidity + " %.");
}
}
}
|