Natural language Communication System Phxnet Team Innovation Training Project blog (vii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.