無(wú)人機(jī)-第一屆報(bào)告項(xiàng)目三_第1頁(yè)
無(wú)人機(jī)-第一屆報(bào)告項(xiàng)目三_第2頁(yè)
無(wú)人機(jī)-第一屆報(bào)告項(xiàng)目三_第3頁(yè)
無(wú)人機(jī)-第一屆報(bào)告項(xiàng)目三_第4頁(yè)
無(wú)人機(jī)-第一屆報(bào)告項(xiàng)目三_第5頁(yè)
已閱讀5頁(yè),還剩24頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

一、app

項(xiàng)目三:基于語(yǔ)音的飛行控實(shí)現(xiàn)功能:利用訊飛demo進(jìn)行語(yǔ)音識(shí)別,并將識(shí)別結(jié)果發(fā)送到電腦端利用訊飛語(yǔ)音識(shí)別的算法提供的接口,寫(xiě)出能夠識(shí)別漢語(yǔ)的activity。DatagramPacketpacket=newDatagramPacket(data,data.length,address,5600);DatagramSocketsocket=newDatagramSocket(); 電腦上的接收端的實(shí)現(xiàn)函數(shù)與上類(lèi)似。“目標(biāo)地址”中輸入電腦的IP地址,點(diǎn)“開(kāi)始識(shí)別”,就可以說(shuō)話了,識(shí)別器如果通信成功示范程序會(huì)輸出類(lèi)似如下的結(jié)(顯示的是的IP地址指令對(duì)照Androidprivateprivatebyte[]GetMessageToSend(Stringstring){Stringmessage="NOP";message=}elseif(string.equals("降落")){message="LND";}elseif(string.equals("向前")){message="FWD";}elseif(string.equals("向后")){message="BCK";}elseif(string.equals("向左")){message="LFT";}elseif(string.equals("向右")){message="RGH";}elseif(string.equals("左轉(zhuǎn)")){message="CNT";}elseif(string.equals("右轉(zhuǎn)")){message="CLK";}elseif(string.equals("沖刺")){message="SPR";}return}packageimportjava.io.IOException;importjava.io.InputStream;importjavanet.DatagramPacket;importjavanet.DatagramSocket;importjavanet.InetAddress;importjavanet.SocketException;importjavaimportjava.util.List;importjava.util.Timer;importjava.util.TimerTask;importandroid.annotation.SuppressLint;importandroid.app.Activity;importandroid.app.AlertDialog;importandroid.app.Dialog;importandroid.content.Context;importandroid.content.Intent;importandroid.content.SharedPreferences;importandroid.content.SharedPreferences.Editor;importandroid.content.pm.PackageInfo;importandroid.graphics.Typeface;importandroid.os.Bundle;importandroid.os.Handler;importandroid.os.Message;importandroid.os.RemoteException;importandroid.text.TextUtils;importandroid.util.Log;importandroid.util.Patterns;importandroid.view.Display;importandroid.view.LayoutInflater;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.view.Window;importandroid.view.WindowManager;importandroid.widget.Button;importimportandroid.widget.SeekBar.OnSeekBarChangeListener;importandroid.widget.TextView;importandroid.widget.Toast;importandroid.widget.SeekBar;importimportcom.iflytek.speech.GrammarListener;importcom.iflytek.speech.ISpee importcom.iflytek.speech.InitListener;importcom.iflytek.speech.LexiconListener;importcom.iflytek.speech.RecognizerListener;importcom.iflytek.speech.RecognizerResult;importcom.iflytek.speech.SpeechConstant;importcom.iflytek.speech.SpeechRecognizer;importcom.iflytek.speech.SpeechUtility;importcom.iflytek.speech.setting.AbnfSettings;importcom.iflytek.speech.util.ApkInstaller;importcom.iflytek.speech.util.JsonParser;importcom.iflytek.speech.util.XmlParser;publicclassAbnfDemoextendsActivityimplementsOnClickListener/*,privatestaticStringTAG="ARDroneSpeechDemo";privatestaticintPORT=5600;privateHandlermHandler;privateDialogmLoadDialog;//璇???寵?????privateSpeechRecognizermRecognizer;privateToastmToast;//緙?瀛privateSharedPreferencesmSharedPreferences;privateSharedPreferencesmParamPreferences;privateStringmLocalGrammar=null;privateStringmCloudGrammar=privatestaticfinalStringKEY_GRAMMAR_ABNF_ID="grammar_abnf_id";privatestaticfinalStringGRAMMAR_TYPE="abnf";privateStringmEngineType=privatebooleanrecognizing=false;privateintthreshold=50;publicvoidonCreate(Bundle{thisrequestWindowFeature(Window.FEATURE_NO_TITLE);mHandler=newMyhandler();mRecognizer=newSpeechRecognizer(this,mInitListener);mToast=ToastmakeText(this,"",Toast.LENGTH_SHORT);Timertimer=newTimer();//瀹?渚????Timer綾?timer.schedule(newTimerTask(){publicvoidrun(){}}privatevoidcheckAndInstallRecognizer(){finalDialogdialog=newLayoutInflaterinflater=ButtonokButton=(Button)alertDialogViewButtoncancelButton=(Button)alertDialogView.findViewById(R.id.cancel);TextViewcomeText=(TextView)alertDialogView.findViewById(R.id.title); spanString.setSpan(newStyleSpan(android.graphics.Typeface.BOLD_ITALIC),0,spanString.length(),SpannableString.SPAN_EXCLUSIVE_INCLUSIVE); TextViewcontentText=(TextView)alertDialogViewfindViewById(R.id.content);okButton.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewv){mLoadDialog=newAlertDialog.Builder(AbnfDemo.this).create();Messagemessage=newMessage();}publicvoidonClick(Viewv){}WindowManagerwindowManager=getWindowManager();Displaydisplay=windowManager.getDefau WindowManager.LayoutParamslpdialog.getWindow().getAttributes();lp.width=(int)(display.getWidth());//璁劇疆瀹藉害}}classMyhandlerextendsHandler{publicvoidhandleMessage(Messagemsg){switch(msg.what){caseStringurl=StringassetsApk=if(processInstall(AbnfDemo.this,url,assetsApk)){Messagemessage=newMessage();message.what=1;}case1:if(mLoadDialog!=null){}}super}}*1.??存?ユ??寮?璇???蟲(chóng)????$??浠朵??〉???錛?榪?琛?涓?privatebooleanprocessInstall(Contextcontext,Stringurl,String// //if(!ApkInstaller.installFromAssets(context,assetsApk)){Toast.makeText(AbnfDemo.this瀹?瑁?澶辮觸",return}return}StringpackageName=List<PackageInfo>packages=for(inti=0;i<packages.size();i++){PackageInfopackageInfo=packages.get(i);returntrue;}}return}*privatevoidinitLayout(){ finalTextViewtext_thre=((TextView)findViewById(R.id.text_thre));OnSeekBarChangeListener(){publicvoidonStopTrackingTouch(SeekBarseekBar)}publicvoidonStartTrackingTouch(SeekBarseekBar)}publicvoidonProgressChanged(SeekBarseekBar,intprogress,booleanfromUser){ifthreshold=progress;if(text_thre!=}}}//mSharedPreferences= mLocalGrammar=readFile("call.bnf","utf-8");mCloudGrammar=mLocalGrammar;mParamPreferences=getSharedPreferences(AbnfSettings.PREFER_NAME, }privateInitListenermInitListener=newInitListener()publicvoidonInit(ISpeeodulearg0,intcode){Log.d(TAG,"SpeechRecognizerinit()code="+code);if(code==ErrorCode.SUCCESS){}}publicvoidonClick(Viewview){{ case Intentintent=new case case int // result=mRecognizer.upda exicon("userword",readFile("userwords","utf-8"),lexiconListener); if(result== }{// result ","", if(result== caseR.id.isr_recognize:recognizing=true;caseR.id.isr_stop:caseR.id.isr_cancel:recognizing=false;}}privatevoidisr_recognize()mParamPreferences.getString("abnf_vadbos_preference","4000"));mParamPreferences.getString("abnf_vadeos_preference","50"));{StringgrammarId={}}{ }//mRecognizer.setParameter(SpeechConstant.PARAMS,"mixed_threshold=20");intrecode=mRecognizer.startListening(mRecognizerListener);if(recode!="+}privatevoidisr_build_grammar(){String[]mGrammars=newString[0];for(Stringgrammar:mGrammars){Log.d("",}StringgrammarContent;{grammarContent=newString(mCloudGrammar);}{grammarContent=newString(mLocalGrammar);}intret=mRecognizer.buildGrammar(GRAMMAR_TYPE,grammarContent,if(ret!="+}protectedvoidonDestroy(){} exiconListenerlexiconListener=newLexiconListener.Stub()publicvoidonLexiconUpdated(Stringarg0,intarg1)throwsRemoteExceptionif(ErrorCode.SUCCESS!=}publicvoidonBuildFinish(StringgrammarId,interrorCode)throwsRemoteException{if(errorCode==ErrorCode.SUCCESS){StringgrammarID=newString(grammarId);Editoreditor=mSharedPreferences.edit();editor.putString(KEY_GRAMMAR_ABNF_ID,grammarID);"+

"+}}*璇???????璋publicvoidonVolumeChanged(intv)throwsRemoteExceptionshowTip("onVolumeChanged錛?"+v);}publicvoidonResult(finalRecognizerResultresult,booleanisLast)throwsRemoteException{runOnUiThread(newRunnable(){publicvoidrun()if(null!=result){{Log.i(TAGrecognizerresult錛?result.getResultString());Stringtext=??Log.i(TAGrecognizerresult錛?result.getResultString());String[]text=??finalintconfidence=Integer.parseInt(text[1]);if(confidence>=Stringaddtext=((EditText)findViewById(R.id.test__ip)).getText().toString();//gettextbyte[]buf=GetMessageToSend(text[0]);InetAddressaddress;tryaddress=InetAddress.getByName(addtext);DatagramPacketpacket=newDatagramPacket(buf,buf.length,address,PORT);DatagramSocketsocket=newDatagramSocket(); }catch(UnknownHostExceptione){}catch(SocketExceptione)}catch(IOExceptione)}}if}}elseLog.d(TAG,"recognizerresult:}}}privatebyte[]GetMessageToSend(Stringstring)Stringmessage=ifstring.equals("璧烽??")){message="TKF";}elseif(string.equals("??????")){message="LND";}elseif(string.equals("??????")){message="FWD";}elseif(string.equals("??????")){message="BCK";}elseifstring.equals("???宸?")){me

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論