felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From don...@apache.org
Subject svn commit: r592049 - in /felix/sandbox/donsez/bunny/src: main/java/org/apache/felix/sandbox/bunny/activator/ main/java/org/apache/felix/sandbox/bunny/impl/ main/java/org/apache/felix/sandbox/bunny/model/ site/
Date Mon, 05 Nov 2007 15:35:40 GMT
Author: donsez
Date: Mon Nov  5 07:35:38 2007
New Revision: 592049

URL: http://svn.apache.org/viewvc?rev=592049&view=rev
Log:
add command to list available voices

Modified:
    felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java
    felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyCommand.java
    felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java
    felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/model/BunnyServiceModel.java
    felix/sandbox/donsez/bunny/src/site/TODOLIST.txt
    felix/sandbox/donsez/bunny/src/site/readme.html
    felix/sandbox/donsez/bunny/src/site/script.txt

Modified: felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java?rev=592049&r1=592048&r2=592049&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java
(original)
+++ felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java
Mon Nov  5 07:35:38 2007
@@ -26,7 +26,6 @@
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
-
 /**
  * this class provides the activator.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -42,6 +41,7 @@
 		bunnyServiceActivator.start(bundleContext);
 		
 		try {
+			// Command is instanciated only if the Felix shell is available
 			Class clazz=this.getClass().getClassLoader().loadClass("org.apache.felix.sandbox.bunny.impl.BunnyCommand");
 			Constructor constructor=clazz.getConstructor(new Class[]{BunnyServiceModel.class});
 			bunnyCommand=(BundleActivator) constructor.newInstance(new Object[] {bunnyServiceActivator
} );

Modified: felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyCommand.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyCommand.java?rev=592049&r1=592048&r2=592049&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyCommand.java
(original)
+++ felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyCommand.java
Mon Nov  5 07:35:38 2007
@@ -19,6 +19,9 @@
 package org.apache.felix.sandbox.bunny.impl;
 
 import java.io.PrintStream;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import org.apache.felix.sandbox.bunny.model.BunnyServiceModel;
@@ -87,6 +90,14 @@
 				String voice=st.nextToken();
 				bunnyServiceModel.configure(null, null, null, voice);
 
+		} else if("voices".equals(subcommand) && n==0){
+			Map voicesLanguages=bunnyServiceModel.getVoicesLanguages();
+			Set voices=voicesLanguages.keySet();
+			for (Iterator iterator = voices.iterator(); iterator.hasNext();) {
+				String voice = (String) iterator.next();
+				out.println(voice+" ("+voicesLanguages.get(voice)+")");
+			}
+
 		} else if("trace".equals(subcommand) && n==1){
 			String trace=st.nextToken();
 			bunnyServiceModel.setTrace("on".equals(trace));
@@ -154,6 +165,7 @@
 		return			getName() + " config <serial number> <token> : configure the bunny'
identifiers"
 		+"\n"+	getName() + " play <left ear pos> <right ear pos> <text to speech>
[<choregraphy>]: speech a text and play a chroregraphy"
 		+"\n"+	getName() + " voice <voice>: set the default voice (eg julie22k,claire22s,caroline22k,bruno22k,graham22s,lucy22s,heather22k,ryan22k,aaron22s,laura22s)"
+		+"\n"+	getName() + " voices : list the available voices"
 		+"\n"+	getName() + " baseurl <baseurl>: set the default base url of the Nabaztag
server or proxy"
 		+"\n"+	getName() + " ears : get ears positions"
 		+"\n"+	getName() + " raw <url encoded params>: send the URL with raw encoded parameters"

Modified: felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java?rev=592049&r1=592048&r2=592049&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java
(original)
+++ felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java
Mon Nov  5 07:35:38 2007
@@ -25,12 +25,13 @@
 import org.apache.felix.sandbox.rest.RESTFulClient;
 import org.osgi.framework.BundleContext;
 import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 /**
  * this class provides implementation of a bunny service.
- * 
+ * TODO add a thread to poll the ears positions and send an event if they have changed 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 
@@ -54,6 +55,8 @@
 
 	private BundleContext bundleContext = null;
 
+	private Map voicesLanguages;
+
 	public BunnyServiceModelImpl(BundleContext bundleContext) {
 		this.bundleContext = bundleContext;
 		loadConfiguration();
@@ -139,6 +142,38 @@
 		RESTFulClient.invokeAndPrint(urlString,parameters);
 	}
 
+	public Map getVoicesLanguages() {
+
+		if(voicesLanguages!=null)
+			return voicesLanguages;
+		else
+			voicesLanguages=new HashMap();
+
+		String urlString = baseUrlString+'?';
+		Map parameters=new HashMap();
+		parameters.put("key",key);
+		parameters.put("sn",serialNumber);
+		parameters.put("token",token);
+		parameters.put("action","9"); // send the ears position
+
+		Document document=RESTFulClient.invoke(urlString,parameters);
+		if(document!=null) {
+			NodeList nodeList;
+			nodeList=document.getElementsByTagName("voice");
+			int len=nodeList.getLength();
+			for(int i=0;i<len;i++){
+				Node voice=nodeList.item(i);
+				NamedNodeMap attributes=voice.getAttributes();
+				String lang=attributes.getNamedItem("lang").getTextContent();
+				String command=attributes.getNamedItem("command").getTextContent();
+				voicesLanguages.put(command, lang);
+			}
+		}
+		return voicesLanguages;
+	}
+
+	
+	
 	public void getEarPositions() {
 
 		String urlString = baseUrlString+'?';

Modified: felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/model/BunnyServiceModel.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/model/BunnyServiceModel.java?rev=592049&r1=592048&r2=592049&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/model/BunnyServiceModel.java
(original)
+++ felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/model/BunnyServiceModel.java
Mon Nov  5 07:35:38 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.sandbox.bunny.model;
 
+import java.util.Map;
+
 /**
  * this interface defines a bunny service.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -51,6 +53,12 @@
 	 */
 	public void sendRawURL(String encodedExtraURLParameters);
 
+	/**
+	 * get the supported languages and voices
+	 * @return
+	 */
+	public Map getVoicesLanguages();
+	
 	/**
 	 * trace the ears positions
 	 */

Modified: felix/sandbox/donsez/bunny/src/site/TODOLIST.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/site/TODOLIST.txt?rev=592049&r1=592048&r2=592049&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/site/TODOLIST.txt (original)
+++ felix/sandbox/donsez/bunny/src/site/TODOLIST.txt Mon Nov  5 07:35:38 2007
@@ -1,8 +1,5 @@
 1) parse rsp response to get positions ... see http://api.nabaztag.com/docs/home.html
-2) save and load the configuration (sn,token,voice)
+2) save and load the configuration (sn,token,voice,baseUrl,eventTopic ...)
 3) add choregraphy classes utilities
-4) test it with 
-
-Links
-* http://api.nabaztag.com/docs/home.html
-* OpenNab (http://sourceforge.net/projects/opennab/) An open PHP-based proxy framework for
the NabaztagĀ™ (http://www.nabaztag.com/) electronic pet. 
+4) test it with a opennab proxy
+5) send  event when ears positions is changed ! (pool the server with ears=ok)

Modified: felix/sandbox/donsez/bunny/src/site/readme.html
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/site/readme.html?rev=592049&r1=592048&r2=592049&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/site/readme.html (original)
+++ felix/sandbox/donsez/bunny/src/site/readme.html Mon Nov  5 07:35:38 2007
@@ -6,6 +6,9 @@
 <h1>org.apache.felix.sandbox.bunny</h1>
 This bundle wraps the API to manage Nabaztag bunny (http://www.nabaztag.com/).
 
+<h2>License</h2>
+License is ASL2 (<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>).
+
 <h2>Service section</h2>
 The bundle registers a org.apache.felix.sandbox.bunny.model.BunnyServiceModel service
 

Modified: felix/sandbox/donsez/bunny/src/site/script.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/site/script.txt?rev=592049&r1=592048&r2=592049&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/site/script.txt (original)
+++ felix/sandbox/donsez/bunny/src/site/script.txt Mon Nov  5 07:35:38 2007
@@ -1,4 +1,6 @@
 
+start mvn:org.apache.felix.sandbox/org.apache.felix.sandbox.bunny
+
 bunny
 
 # configure the serial number and the token of your Nabaztag
@@ -31,11 +33,24 @@
 
 
 # with EventAdmin (event.topics is org/apache/felix/sandbox/bunny)
-obr start "Apacke Felix Event Admin"
+obr start "Apache Felix Event Admin"
 start eventadmincmd/eventadmincmd.jar
 eventadmin subscribe org/apache/felix/sandbox/bunny
 eventadmin send org/apache/felix/sandbox/bunny voice=aaron22s&tts=hello+world+the+sun+shines+today+but+the+weather+may+be+cloudy+this+afternoon
 
+start mvn:org.apache.felix.sandbox/org.apache.felix.sandbox.event.convertor
+eventconvertor blogs/felixdev org/apache/felix/sandbox/bunny tts=title
+eventadmin send blogs/felixdev title=Felix+is+an+open+source+platform
+
+# set the base url to a Nabaztag proxy to speed up actions processing
+bunny baseurl http://192.168.0.66/vl/
+
+bunny voice claire22k
+bunny play 8 8 salut+Felix,+tu+as+le+boujour+de+la+bande 10,0,motor,1,20,0,0,200,led,2,0,238,0,2,led,1,250,0,0,3,led,2,0,0,0
+
+bunny voice maria22k
+bunny play 1 3 Hola,+Que+tal.Que+pasa+por+la+calle.+No+pasa+nada.+No+pasa+nada
+
 
 # send actions with the raw sub-command
 bunny raw action=2
@@ -43,11 +58,19 @@
 bunny raw action=4
 bunny raw action=5
 bunny raw action=6
+
 bunny raw action=7
+
+#Get to know if the Nabaztag is a Nabaztag (V1) or a Nabaztag/tag (V2)
 bunny raw action=8
+
+# Get a list of all supported languages/voices for TTS (text to speach) engine
 bunny raw action=9
+
+
 bunny raw action=10
 bunny raw action=11
+
 # bunny raw action=12
 # bunny raw action=13
 



Mime
View raw message