這篇文章主要介紹“怎么用Java實現(xiàn)語音測試”,在日常操作中,相信很多人在怎么用Java實現(xiàn)語音測試問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么用Java實現(xiàn)語音測試”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:主機域名、網(wǎng)頁空間、營銷軟件、網(wǎng)站建設(shè)、芮城網(wǎng)站維護、網(wǎng)站推廣。
我錄了一段音存儲在這個test.m4a文件里,語音內(nèi)容為"測試一下Netweaver對于并發(fā)請求的響應性能"。
使用如下Java代碼進行測試:
package com.iflytek.msp.lfasr;import java.util.HashMap;import org.apache.log4j.Logger;import com.alibaba.fastjson.JSON;import com.iflytek.msp.cpdb.lfasr.client.LfasrClientImp;import com.iflytek.msp.cpdb.lfasr.exception.LfasrException;import com.iflytek.msp.cpdb.lfasr.model.LfasrType;import com.iflytek.msp.cpdb.lfasr.model.Message;import com.iflytek.msp.cpdb.lfasr.model.ProgressStatus;// SDK document: http://www.xfyun.cn/doccenter/lfasr#go_sdk_doc_v2public class TestLfasr { // original media path private static final String local_file = "c:\\temp\\test.m4a"; private static final LfasrType type = LfasrType.LFASR_STANDARD_RECORDED_AUDIO; private static int sleepSecond = 20; public static void main(String[] args) { LfasrClientImp lc = null; try { lc = LfasrClientImp.initLfasrClient(); } catch (LfasrException e) { Message initMsg = JSON.parseObject(e.getMessage(), Message.class); System.out.println("ecode=" + initMsg.getErr_no()); System.out.println("failed=" + initMsg.getFailed()); } // get upload task id String task_id = ""; HashMapparams = new HashMap<>(); params.put("has_participle", "true"); try { Message uploadMsg = lc.lfasrUpload(local_file, type, params); int ok = uploadMsg.getOk(); if (ok == 0) { task_id = uploadMsg.getData(); System.out.println("task_id=" + task_id); } else { System.out.println("ecode=" + uploadMsg.getErr_no()); System.out.println("failed=" + uploadMsg.getFailed()); } } catch (LfasrException e) { Message uploadMsg = JSON.parseObject(e.getMessage(), Message.class); System.out.println("ecode=" + uploadMsg.getErr_no()); System.out.println("failed=" + uploadMsg.getFailed()); } while (true) { try { Thread.sleep(sleepSecond * 1000); System.out.println("waiting ..."); } catch (InterruptedException e) { } try { Message progressMsg = lc.lfasrGetProgress(task_id); if (progressMsg.getOk() != 0) { System.out.println("task was fail. task_id:" + task_id); System.out.println("ecode=" + progressMsg.getErr_no()); System.out.println("failed=" + progressMsg.getFailed()); continue; } else { ProgressStatus progressStatus = JSON.parseObject(progressMsg.getData(), ProgressStatus.class); if (progressStatus.getStatus() == 9) { System.out.println("task was completed. task_id:" + task_id); break; } else { System.out.println("task was incomplete. task_id:" + task_id + ", status:" + progressStatus.getDesc()); continue; } } } catch (LfasrException e) { Message progressMsg = JSON.parseObject(e.getMessage(), Message.class); System.out.println("ecode=" + progressMsg.getErr_no()); System.out.println("failed=" + progressMsg.getFailed()); } } try { Message resultMsg = lc.lfasrGetResult(task_id); System.out.println(resultMsg.getData()); if (resultMsg.getOk() == 0) { System.out.println(resultMsg.getData()); } else { System.out.println("ecode=" + resultMsg.getErr_no()); System.out.println("failed=" + resultMsg.getFailed()); } } catch (LfasrException e) { Message resultMsg = JSON.parseObject(e.getMessage(), Message.class); System.out.println("ecode=" + resultMsg.getErr_no()); System.out.println("failed=" + resultMsg.getFailed()); } } }
(1) 所有中文均能成功轉(zhuǎn)成文字; 但英文Netweaver的語音轉(zhuǎn)換成了Net ball
(2) 智能分詞也能按照期望工作,比如“測試一下”成功地分詞成了“測試”和“一下”。
到此,關(guān)于“怎么用Java實現(xiàn)語音測試”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
網(wǎng)站名稱:怎么用Java實現(xiàn)語音測試
文章地址:http://weahome.cn/article/gdjchj.html