Monthly Archives: May 2012

Facebook IPO roller coaster and investment

I thought it was time to actually write something down about this, as it is taking proportions that I really would not have predicted : Investing your money in shares is very risky ! If you didn’t know that before you invested, then you were simply reckless and if you did know it, then you do not have a right to complain.

Short term fluctuations in share prices are driven by speculation and not real company results. Facebook didn’t dramatically decrease their revenue over the past few days, nor did it release an amazingly bad feature that scared all of it’s users away. The only reason the share price is going down is because analysts are revising their optimism over the future of the business and their revenue potential.

In the long run, however, the share price will reflect actual results and the performance of the business compared to what people expected of it. If in the long run, Facebook under-delivers, you have a right to complain : they sold you a vision that was either wrong or badly executed. However, for this you have to give them some time : they have no control over the current fluctuations.

I bought a few shares in Facebook myself, simply for the sake of being “in the game”. However, I didn’t invest my life savings or anything I couldn’t lose because I didn’t want to risk it. If you don’t want to risk losing your money, then don’t invest but do not turn around and blame the company for a share price they only partly control.

Robot Control Software through Player / Stage

This semester, we had to write some Robot Control Software for a Vacuum cleaning robot based on the Player / Stage environment.

The robot is :

  • Dynamically mapping the environment
  • Cleaning the area while it moves along
  • Avoiding obstacles when it finds them on it’s path

Everything is written in Java and pretty well documented. (Code to be added soon)

Here is a quick video of the final software running :

Android voice control

I have been playing with Android development for quite a while, but two weeks ago I finally finished my first Application. I thought that Text-to-Speech and Speech-to-Text were pretty amazingly easy to integrate and thought I could make everyone benefit from a few snippits, so here is my code (it was almost all done in a single class) :


package com.findarato.cyanide;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class CyanideRobotActivity extends Activity implements OnClickListener, OnInitListener, OnUtteranceCompletedListener {

private static final int VOICE_RECOGNITION_REQUEST_CODE = 12345;

EditText server = null;
EditText port = null;

TextToSpeech tts = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);

final Button buttonStart = (Button) findViewById(R.id.button_start);
final Button buttonStop = (Button) findViewById(R.id.button_stop);
final Button buttonSpeech = (Button) findViewById(R.id.button_speech);
tts = new TextToSpeech(this, this);
tts.setOnUtteranceCompletedListener(this);
server = (EditText) findViewById(R.id.text_ip);
port = (EditText) findViewById(R.id.text_port);

port.setText("9002");

buttonStart.setOnClickListener(this);
buttonStop.setOnClickListener(this);
buttonSpeech.setOnClickListener(this);

}

private void startVoiceRecognitionActivity() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Please tell the robot what to do.");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 20);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String serverString = server.getText().toString();
int portInt = Integer.parseInt(port.getText().toString());

if(requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
for(String match : matches) {
if(match.equalsIgnoreCase("start robot") || match.equalsIgnoreCase("start") || match.equalsIgnoreCase("start cleaning")) {
tts.speak("Starting cleaning now", TextToSpeech.QUEUE_FLUSH, null);
new networkRequest(serverString, portInt, "START").execute();
}
else if(match.equalsIgnoreCase("stop robot") || match.equalsIgnoreCase("stop") || match.equalsIgnoreCase("stop cleaning")) {
tts.speak("Stopping cleaning now, returning to my charging dock.", TextToSpeech.QUEUE_FLUSH, null);
new networkRequest(serverString, portInt, "STOP", true).execute();
}
}
super.onActivityResult(requestCode, resultCode, data);
}
}

@Override
public void onClick(View v) {

String serverString = server.getText().toString();
int portInt = Integer.parseInt(port.getText().toString());

switch(v.getId()) {
case R.id.button_start :
new networkRequest(serverString, portInt, "START").execute();
break;
case R.id.button_stop :
new networkRequest(serverString, portInt, "STOP").execute();
break;
case R.id.button_speech :
HashMap<String, String> extra = new HashMap<String, String>();
extra.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "start voice recognition");
tts.speak("Hello master, what would you like me to do ?", TextToSpeech.QUEUE_ADD, extra);
break;
default:
break;
}

}

@Override
public void onInit(int status) {
// TODO Auto-generated method stub

}

@Override
public void onUtteranceCompleted(String utteranceId) {
if(utteranceId.equals("start voice recognition"))
startVoiceRecognitionActivity();
}
}

The interesting parts are the methods startVoiceRecognitionActivity() and onClick(View v) -> switch statement R.id.button_speech

EDIT : I have created a gihub repo for this, if anyone is interested : https://github.com/JoshuaWohle/Android-Voice-Control