vText for Java

The voice password component for Java

Download

Usage Example:

//import
import com.mathworks.toolbox.javabuilder.*;
import vText.*;
import java.io.File;
import java.net.FileNameMap;
import javax.swing.filechooser.FileSystemView;

//Class Declaration vTextClass vTText = null; /* Stores VTText instance */
String source = "C:" + File.separator + "wav" + File.separator + "source";
String compare = "C:" + File.separator + "wav" + File.separator + "compare";
String filteredfilename = "C:" + File.separator + "wav" + File.separator + "filtered";
Object[] result = null; /* Stores the result */
vTText = new vTextClass();

//Recording voice
try {
vTText.dataAcq(1, source);
System.out.println("Recording completed");
} catch (Exception e) {
System.out.println("Exception: " + e.toString());
}
Alternatively you can record voice using java's own library or api as long as the voice's technical properties are set the same, that are
-Frequency: 8000Hz
-Recording duration: 4 or 5 seconds
-The file format is wav
-This alternative may be needed because the last compilation of vText is around 2013 and may not be compatible with new driver or hardware

//Compare voice
try {
result = vTText.recognizePartial10k(1, source, compare, "0.5", "1.5");
System.out.println("voice password result=" + result[0].toString()+ "/100");
} catch (Exception e) {
System.out.println("Exception: " + e.toString());
}

//Frequency Spectra: how to store sequential frequency blocks in database table
double col1 = 0;//table.field1
double col2 = 0;
double col3 = 0;
//repeat till col100
try
{
result = vTText.complexmodulus(1, source);
double[][] ret = new double[result.length][];
ret[0] = (double[])((MWArray)result[0]).getData();
for (int i = 0; i < 10000; i++)
{
System.out.println("magnitude of sample " + (i+1) + " = " + ret[0][i]);
if (i<100)
{
col1=col1 + ret[0][i]);
}
elseif (i>99 && i<200)
{
col2=col2 + ret[0][i]);
}
elseif (i>199 && i<300)
{
col3=col3 + ret[0][i]);
}
//repeat till col100
}
//Store col1 in table.field1
//Store col2 in table.field2
//Store col3 in table.field3
//...
//Store until Col100
} catch (Exception e) {
System.out.println("Exception: " + e.toString());
}

Note:
1. We need to have 2 source signals to be stored in the database table for each person, and the 2 source signals comparison score must match >= 77% before it can be stored in the database table.
2. The following is the way to compare and obtain the % score
-The comparison is done by dividing the incoming signal over the source record for each column. If the result of col1 is between 0.5 and 1.5, then it's 1% matched, continue this until the 100th column. If 70 columns' value is within 0.5 and 1.5, it's 70% matched
-For example:
-if user1.col1 (source) = 70 and if user2.col1 (incoming) = 100, then 100/70 = 1.43. this is considered within 0.5 and 1.5, therefore achieve 1% matched
-if user1.col2 (source) = 90 and if user2.col2 (incoming) = 50, then 50/90 = 0.56. this is considered within 0.5 and 1.5, therefore achieve another 1% matched. the total now is 2% matched
-if user1.col3 (source) = 30 and if user2.col3 (incoming) = 70, then 70/30 = 2.33. this is considered outside 0.5 and 1.5, therefore achieve 0% matched. the total now is still 2% matched
-repeat the above process till col100
3. The incoming signal record should compare against both the source records in the database, any comparison which achieves score >= 70% should suffice for the start. However, you can increase the threshold when necessary to improve level of security

Compilation and running the program

  • Create a JAVA_HOME at environment variable, the value is something like C:\Program Files (x86)\Java\jdk1.8.0_161
  • From the usage sample create a TestVoice.java and place it in c:\basic\. Note this file is initially created in Netbean
  • In the command prompt c drive, type cd \basic
  • Setting the path:
    • set path=%path%;C:\Program Files\Java\jdk1.8.0_161\bin;C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\v714\bin;C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\v714\runtime\win32;
  • Run the compilation command:
    • javac -classpath ".;C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\v714\toolbox\javabuilder\jar\javabuilder.jar;C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\v714\toolbox\javabuilder\jar\vText.jar" TestVoice.java
  • Then TestVoice.classes will be generated at c:\basic\classes\TestVoice\
  • Copy the javabuilder.jar from:
    • C:\Program Files (x86)\MATLAB\MATLAB Compiler Runtime\\v714\toolbox\javabuilder\jar\
    • To:
    • c:\basic\classes\TestVoice\
    • Also copy the downloaded vText.jar (not the installed vText.jar) to c:\basic\classes\TestVoice
  • To run the program, type:
    • java -cp ./classes;./classes/testvoice/vText.jar;./classes/testvoice/javabuilder.jar;. testvoice.TestVoice /jars/common.jar

Enquiry or Implementation:

  • Please contact enquiry@basic-signalprocessing.com.

© 2019 - Basic Signal Processing Services. Glory be to the Father and to the Son and to the Holy Spirit