Technical summary of "Voice to text" used in this project:
The voice-to-text part is the call of the Iflytek's online voice, its excitation mode is the key, through the button trigger to open the audio recording of Android device, this part needs to write about the requirements of Android rights in the source code, to invoke the recording rights of Android, when the button is fired, then start to enter the voice recording stage, The voice recorded in the microphone is transmitted to the cloud's Iflytek server in real time. 、
Get the text from the sound:
Public void Getwordfromvoice () {
boolean isshowdialog = Msharedpreferences.getboolean ("Iat_show", true);
if (Isshowdialog) {
Showiatdialog ();
} Else {
if (null = = Iatrecognizer) {
Iatrecognizer = SpeechRecognizer. Createrecognizer (this);
}
if (Iatrecognizer.islistening ()) {
Iatrecognizer.stoplistening ();
} Else {
}
}
}
The borrowed interface is the interface provided by Iflytek Open platform, realizes real-time voice transmission, through the cloud server using the Iflytek voice packet to convert the voice to text, back to the client, so that the client's voice to the text, to get the required text, The client processing method is to send the received text text into the Unity3d, and then through the Unity3d text text sent to the server side, the next step by the server for voice intelligent recognition, the main predicate phrase segmentation, call the relevant library to reply.
Here's how to invoke the Voicetotext interface:
@Override
Public void OnClick (View v) {
Switch (V.getid ()) {
Case R.id. button1:
Voicetoword voice = new voicetoword (mainactivity. this, "54ae8c54");
Voice. Getwordfromvoice ();
break;
}
}
Sound monitoring:
Private Speechlistener listener = new Speechlistener () {
@Override
Public void onData (byte[] arg0) {
}
@Override
Public void oncompleted (speecherror error) {
if (Error! = null) {
System. out. println ("User login Success");
}
}
Natural language Communication System Phxnet Team Innovation Training Project blog (vii)