-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="lib/asrtsdk-1.0.rc1.jar"/> | ||
<classpathentry kind="lib" path="lib/gson-2.9.0.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>asrtcli</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* | ||
*/ | ||
package asrtcli; | ||
|
||
import net.ailemon.asrt.sdk.*; | ||
import net.ailemon.asrt.sdk.models.*; | ||
import net.ailemon.asrt.sdk.common.*; | ||
/** | ||
* @author ailemon | ||
* | ||
*/ | ||
public class Main { | ||
|
||
/** | ||
* @param args | ||
*/ | ||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
String host = "127.0.0.1"; | ||
String port = "20001"; | ||
String protocol = "http"; | ||
BaseSpeechRecognizer sr = Sdk.GetSpeechRecognizer(host, port, protocol); | ||
String filename = "C:\\Users\\ailemon\\Desktop\\data.wav"; | ||
if(args.length > 0){ | ||
filename = args[0]; | ||
} | ||
// ============================================ | ||
// 直接调用ASRT识别语音文件 | ||
AsrtApiResponse rsp = sr.RecogniteFile(filename); | ||
System.out.println(rsp.statusCode); | ||
System.out.println(rsp.statusMessage); | ||
System.out.println(rsp.result); | ||
|
||
// ============================================ | ||
// 调用ASRT识别语音序列 | ||
byte[] wavBytes = Common.readBinFile(filename); | ||
Wave wav = new Wave(); | ||
wav.deserialize(wavBytes); | ||
byte[] sampleBytes = wav.getRawSamples(); | ||
int sampleRate = wav.sampleRate; | ||
int channels = wav.channels; | ||
int byteWidth = wav.sampleWidth; | ||
rsp = sr.Recognite(sampleBytes, sampleRate, channels, byteWidth); | ||
System.out.println(rsp.statusCode); | ||
System.out.println(rsp.statusMessage); | ||
System.out.println(rsp.result); | ||
|
||
// ============================================ | ||
// 调用ASRT声学模型识别语音序列 | ||
wavBytes = Common.readBinFile(filename); | ||
wav = new Wave(); | ||
wav.deserialize(wavBytes); | ||
sampleBytes = wav.getRawSamples(); | ||
sampleRate = wav.sampleRate; | ||
channels = wav.channels; | ||
byteWidth = wav.sampleWidth; | ||
rsp = sr.RecogniteSpeech(sampleBytes, sampleRate, channels, byteWidth); | ||
System.out.println(rsp.statusCode); | ||
System.out.println(rsp.statusMessage); | ||
System.out.println(rsp.result); | ||
|
||
// ============================================ | ||
// 调用ASRT语言模型识别拼音序列1 | ||
String[] pinyins = ((String)rsp.result).split(", "); | ||
rsp = sr.RecogniteLanguage(pinyins); | ||
System.out.println(rsp.statusCode); | ||
System.out.println(rsp.statusMessage); | ||
System.out.println(rsp.result); | ||
|
||
// ============================================ | ||
// 调用ASRT语言模型识别拼音序列2 | ||
pinyins = new String[]{"ni3", "hao3", "a1"}; | ||
rsp = sr.RecogniteLanguage(pinyins); | ||
System.out.println(rsp.statusCode); | ||
System.out.println(rsp.statusMessage); | ||
System.out.println(rsp.result); | ||
|
||
} | ||
|
||
} |