Speech Recognizer In Java – CMUSphinx [HD]

Speech Recognizer in java using Eclipse SDK.

I’m using Sphinx 4. It’s a Speech Recognizer API (no synthesizer) written in java. Sphinx 4 is an implementation of Java Speech API (JSAPI) 1.0.

Requirements to work according to the tutorial :

1 ) JDK 6 ( J2SE )

2 ) Eclipse SDK ( Im using Eclipse 3.4.0 )

3 ) Sphinx 4.0

4 ) JSAPI ( Included in Sphinx 4.0 )

Other Articles :

Basics of Java Speech Grammar Format ( JSGF )

https://puneetk.com/basics-of-java-speech-grammar-format-jsgf

Expanding Dictionary Of Acoustic Model

https://puneetk.com/expanding-dictionary-of-acoustic-model

How To Improve Accuracy ( Sphinx 4 )

https://puneetk.com/how-to-improve-accuracy-sphinx-4

Object Detection and Segmentation – Android

Object Detection and Segmentation application for Android.

Screenshots and video, both are taken on Samsung Galaxy Tab 2 7.0

I developed this application as project assignment which unfortunately didn’t go well. So, I’m sharing results here. Please feel free to share your thoughts.

CodeIgniter – Get controller or method name

Hey everyone!

Ever since I wrote a few posts on CodeIgniter and published Facebook PHP SDK for CodeIgniter library, and I have been asked this very same question many times. How to get name of current controller (Class) and method (Function)?

Its pretty simple one line code and can be easily found through Google. But there’s a lot of confusion and multiple codes depending on different versions. So I decided to share the code which I have been using on every website that I develop based on CI and works perfectly on the current version of CI v2.1.4.


$controller = $this->router->fetch_class(); // for controller


$method = $this->router->fetch_method(); // for method

That’s it! Just simple one line code. But there’s another thing I would like to share, Which is the best way to declare such variables so its available on all controllers and methods?

Obviously you are not going to execute same line on every controller or method (Seriously that’s a bad idea). This is really important as you will not be using just these 2 variables, you may also want site settings and menus to be available everywhere. So my idea to implement this is declare those variables in Controller.php file in CI_Installation/System/Core folder.

Instead of declaring $data variable to load view in every controller or every method. I prefer declaring it as array in Core CI_Controller class which is parent class of all controllers. So the $this->data variable is available and editable everywhere. Not just for variables, If you can also do some pre-processing such as loading data from cache and request validations by declaring functions and invoking them in constructor of CI_Controller class.

Here’s the sample code, this will give you an idea how I do it for my projects and if you have any better way, please feel free to share with me in comments!

Signing off! Puneet

Facebook PHP SDK for CodeIgniter

Integrating Facebook PHP SDK is not that hard, it only takes few minutes to do that. But its completely different story when you are integrating it with CodeIgniter.

Thats because Facebook PHP SDK takes input from $_REQUEST variable while CodeIgniter purges the $_REQUEST variable for security reasons. Other important reason is theres no dedicated library available for it (while there are few available for Twitter) and there is vast range of solutions if you search for it but no proper solution (atleast I didn’t find one).

So I decided to create one and worked on it last week.

Facebook PHP SDK for CodeIgniter on Github

There are four folders config, controllers, libraries and views. All you need to do is, copy these folders to application folder of your CI installation.

Then replace your facebook application id and secret in facebook.php file under config folder:

$config['appId']   = 'APP_ID_HERE';

$config['secret']  = 'SECRET_HERE';

And thats it. Try accessing domain.com/welcome/login (localhost if testing locally).

 

Few things to double check:

  1. Your FB application is not on Sandbox mode.
  2. Your website domain (or localhost if testing locally) is listed in app domains.
  3. Website with Facebook Login is enabled and pointed to your domain.
  4. App type is set to Web under advance settings.
  5. Client OAuth Login is enabled under advance settings.