Wednesday, September 21, 2011

Sphinx Video Tutorial

Running the demonstration programs

Simple demos to start with sphinx4

  • Hello World Demo: a command line application that recognizes simple phrases.
  • Hello N-Gram Demo: a command line application using an N-gram language model for speech recognition

Demos for audio file transcription

  • Transcriber Demo: a simple demo program showing how to transcribe a continuous audio file that has multiple utterances separated by silences.
  • Confidence Demo: a simple demo program showing how to obtain confidence scores for result.
  • Lattice Demo: a simple demo program showing how to extract lattices from recognition results.
  • Class-Based Language model Demo: a simple demo of the class based language model.
  • Aligner Demo: aligns audio file to transcription and get times of words. Can be useful for closed captioning.

Dialog demos to write advanced dialog system

  • ZipCity Demo: a Java Web Start technology application that recognizes spoken zip codes and locates the associated city and state.
  • JSGF Demo: a simple demo program showing how a program can swap between multiple JSGF grammars.
  • Dialog Demo: a demo program showing how a program can swap between multiple JSGF and dictation grammars.
  • Action Tags Demo: a demo program showing how to use action tags for post-processing of RuleParse objects obtained from JSGF grammars.

Saturday, June 11, 2011

Expanding Dictionary Of Acoustic Model

Hello Everyone,

Today I’m going to tell you how to expand dictionary of acoustic model for Sphinx4. In simple words, This tutorial will tell you how you can add more words in Sphinx’s words database (Dictionary) and let it recognize those words, which are not available in default acoustic models provided by CMU Sphinx. This tutorial is based on “HelloWorld” example provided by CMU Sphinx.

Important Files in this example :
1 ) HelloWorld.java
2) hello.gram
3) helloworld.config.xml

Acoustic Model used in this example :
WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar

Lets say, We are creating a SR system for ABC National airlines. Everything will go fine and Sphinx will recognize most of the words except the name of cities and states of India. Now, I will tell you, How to add name of cities and states in dictionary.

PART ONE
Step 1 :
Create a txt file “words.txt”, Write all the names of cities and states in it and save.
Step 2 : Open this link : http://www.speech.cs.cmu.edu/tools/lmtool.html
Step 3 : On that page, go to “Sentence corpus file:” section, Browse to “words.txt” file and click “Compile Knowledge Base”.
Step 4 : On next page, Click on “Dictionary” link and save that .DIC file.

PART TWO
Step 1 : Extract WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar file.
Step 2 : Go to edu\cmu\sphinx\model\acoustic\WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz\dict folder.
Step 3 : Open “cmudict.0.6d” file in that folder.
Step 4 : Copy data from .DIC file, you have downloaded in PART ONE, paste it in “cmudict.0.6d” file and save.

Step 5 : Go to command prompt & travel to sphinx4-1.0beta5\lib folder
run following command

jar -cf WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz

Step 6 : Refresh Project in eclipse & run project

Reference : For this valuable tutorial i would like to thanks Mr. Puneet Kalra for his guidance provided on his website.


If any doubt feel free to write me

You can also refer to the video showing how it actually works


Friday, April 15, 2011

Hindi Speech Recognizer in java

This tutorial will explain you how to recognize Hindi Words using Sphinx4 Java API

Requirements :
If you don't have above software please download it by clicking respective software name.

Implementing Hindi Speech Recognizer:
  • Install JDK 6.
  • Extract Sphinx 4 to any drive (preferably C Drive).
  • Go to C:\sphinx4-1.0beta5\lib and run jsapi.exe file.This will create jsapi.jar file in same folder.
  • Open Eclipse and select Workspace for your project.
  • File -> New -> Java Project. Give Project name as HindiSpeechRecognizer.
  • Adding jars to project
    • Right Click on Project name and go to properties.
    • Click on Java Build Path and Select Libraries.
    • Add Library -> User Library -> User Libraries -> New.Give User Library name as sphinx and prees Ok.
    • Click on newly created Library and select add JAR's
    • Add following JAR's to Library
      • js.jar Path=C:\sphinx4-1.0beta5\lib
      • jsapi.jar Path=C:\sphinx4-1.0beta5\lib
      • Sphinx4.jar Path=C:\sphinx4-1.0beta5\lib
      • tags.jar Path=C:\sphinx4-1.0beta5\lib
      • HelloWorld.jar Path=C:\sphinx4-1.0beta5\bin
  • Extract Source Files for Recognizer and replace 'src' folder with 'src' folder of 'HindiSpeechRecognizer' Project.
  • Replace WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar file with C:\sphinx4-1.0beta5\lib\WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar file
  • Refresh 'HindiSpeechRecognizer' Project.
  • Run HindiRecognizer.java file
If any doubt feel free to write me

Friday, April 1, 2011

How to send message to mobile using SMTP

Following code will send SMS to any phone number using your Way2SMS account


import java.rmi.RemoteException;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Random;
import java.lang.Integer;
import java.io.*;
import javax.microedition.io.*;

/**
* @author kiLLer
*/
public class Midlet2 extends MIDlet implements CommandListener {
private Command exitCommand; // The exit command
private Command okCommand; // The exit command
private Command cancelCommand; // The exit command
private Command nextCommand; // The exit command
private Command backCommand; // The exit command
private Display display; // The display for this MIDlet

public Midlet2() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.EXIT, 2);
}
public void startApp() {
String rslt = null;
boolean isCalled = false;

sendsms("http://ubaid.tk/sms/sms.aspx?uid=Your_Phone_Number&pwd=Your_Way2SMS_Password&msg=TESTING IS DONE 5525&phone=9920965650&provider=way2sms");
int rn = RandomNo();
String rndm = Integer.toString(rn);
TextBox t = new TextBox("Hello", "......"+rndm, 256, 0);
t.addCommand(exitCommand);
t.setCommandListener(this);

display.setCurrent(t);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
throw new UnsupportedOperationException("Not supported yet.");
}
}

public int RandomNo()
{
Random r=new Random(System.currentTimeMillis());
int rno= Math.abs(r.nextInt());
return (1000 + rno % 7000);
}

public void sendsms(String url)
{
HttpConnection connection = null;
InputStream inputstream = null;
try {
connection = (HttpConnection) Connector.open(url);
connection.setRequestMethod(HttpConnection.GET);
connection.setRequestProperty("Content-Type","//text plain");
connection.setRequestProperty("Connection", "close");
} catch (Exception ex) {}
}
}

You have to make following changes in sendsms function

  • change uid to your phone number
  • change pwd to your Way2sms account password
  • change msg to message you want send to the user
  • change phone to receivers phone number
After calling sendsms function you will one of the following two replies
  • 1 : SMS sent
  • 2 : some error
This code somehow won't work for BPL phone numbers so use different network provider