资源简介
javaweb实现语音识别,将语音转换成文字并输出,调用百度接口,需要自己注册账号。
代码片段和文件信息
package com.xin.voice.controller;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.xin.voice.util.SampleClient;
/**
* H5 录音实现
* @author liyingming
*
*/
@Controller
@RequestMapping(value = “/voiceSpeech“)
public class VoiceSpeechController {
SampleClient sc = new SampleClient(); //语音识别核心类
/**
* 访问录音页面
* @return
* @throws Exception
*/
@RequestMapping(value = “/voice.do“)
public ModelAndView queryVoice() throws Exception {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName(“/voice/voiceIndex“);
return modelAndView;
}
/**
* 保存录音
* @date 2017年9月25日 上午10:33:48
* @param audioData
* @return
* @throws Exception
*/
@RequestMapping(value = “/save.do“)
@ResponseBody
public Mapject> save(MultipartFile audioDataHttpServletRequest request){
Mapject> modelMap = new HashMapject>();
try {
//保存录音
String filePathName =saveAudio(audioData);//返回音频路径名称
//识别录音
String Rtext = “未识别清楚“;
if ((filePathName)!=““) {
Rtext = sc.getSynthesis(filePathName);
modelMap.put(“success“ true);
}
System.out.println(“语音识别的内容:“ + Rtext);
modelMap.put(“Rtext“ Rtext);
} catch (Exception e) {
e.printStackTrace();
modelMap.put(“success“ false);
modelMap.put(“data“ e.getMessage());
}
return modelMap;
}
/**
* 保存音频文件
* @param audioData
* @return
*/
private String saveAudio(MultipartFile audioData){
try {
String filePathName = null;
String fName = System.currentTimeMillis() + “.wav“;
String fPath = “C:/testvoice“;
//将录音的文件存放到F盘下语音文件夹下
File filePath = new File(fPath);
if(!filePath.exists())
{//如果文件不存在,则创建该目录
filePath.mkdir();
}
filePathName = fPath+“/“+fName;
FileOutputStream os = new FileOutputStream(filePathName);
System.out.println(“路径:“+filePathName);
InputStream in = audioData.getInputStream();
int b = 0;
while((b=in.read())!=-1){ //读取文件
os.write(b);
}
os.flush(); //关闭流
in.close();
os.close();
return filePathName;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4005 2017-12-11 23:26 语音识别HTML5版本\voiceTest\.classpath
文件 303 2014-12-26 10:53 语音识别HTML5版本\voiceTest\.myme
文件 1752 2017-11-09 09:39 语音识别HTML5版本\voiceTest\.project
文件 500 2014-11-03 14:02 语音识别HTML5版本\voiceTest\.settings\.jsdtscope
文件 248 2017-12-11 12:52 语音识别HTML5版本\voiceTest\.settings\com.genuitec.eclipse.migration.prefs
文件 57 2018-03-14 15:23 语音识别HTML5版本\voiceTest\.settings\org.eclipse.core.resources.prefs
文件 670 2017-11-09 09:39 语音识别HTML5版本\voiceTest\.settings\org.eclipse.jdt.core.prefs
文件 106 2017-11-09 09:39 语音识别HTML5版本\voiceTest\.settings\org.eclipse.ltk.core.refactoring.prefs
文件 570 2017-11-09 09:39 语音识别HTML5版本\voiceTest\.settings\org.eclipse.wst.common.component
文件 172 2017-12-11 12:52 语音识别HTML5版本\voiceTest\.settings\org.eclipse.wst.common.project.facet.core.prefs.xm
文件 219 2017-11-09 09:39 语音识别HTML5版本\voiceTest\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2014-11-03 14:02 语音识别HTML5版本\voiceTest\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2014-11-03 14:02 语音识别HTML5版本\voiceTest\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 842 2014-12-29 11:06 语音识别HTML5版本\voiceTest\app-config\config\applicationContext.xm
文件 3099 2018-03-14 14:56 语音识别HTML5版本\voiceTest\src\com\xin\voice\controller\VoiceSpeechController.java
文件 3108 2018-03-22 14:31 语音识别HTML5版本\voiceTest\src\com\xin\voice\util\AuthService.java
文件 1966 2018-03-22 14:31 语音识别HTML5版本\voiceTest\src\com\xin\voice\util\SampleClient.java
文件 2030 2017-12-12 11:33 语音识别HTML5版本\voiceTest\src\com\xin\voice\util\SampleClient.java.bak
文件 40 2017-12-11 12:52 语音识别HTML5版本\voiceTest\src\me
文件 834 2014-11-03 14:02 语音识别HTML5版本\voiceTest\WebContent\index.jsp
文件 7793 2018-03-14 15:40 语音识别HTML5版本\voiceTest\WebContent\js\HZRecorder.js
文件 93682 2018-03-14 15:40 语音识别HTML5版本\voiceTest\WebContent\js\jquery-1.8.3.min.js
文件 39 2017-11-09 09:39 语音识别HTML5版本\voiceTest\WebContent\me
文件 4176 2017-11-13 16:48 语音识别HTML5版本\voiceTest\WebContent\voice\1510562930942.mp3
文件 4176 2017-11-13 16:48 语音识别HTML5版本\voiceTest\WebContent\voice\1510562931523.mp3
文件 4176 2017-12-11 15:31 语音识别HTML5版本\voiceTest\WebContent\voice\1512977484954.mp3
文件 4176 2017-12-11 15:32 语音识别HTML5版本\voiceTest\WebContent\voice\1512977549596.mp3
文件 4176 2017-12-11 15:33 语音识别HTML5版本\voiceTest\WebContent\voice\1512977593181.mp3
文件 4176 2017-12-11 15:33 语音识别HTML5版本\voiceTest\WebContent\voice\1512977600189.mp3
文件 4176 2017-12-11 15:33 语音识别HTML5版本\voiceTest\WebContent\voice\1512977615294.mp3
............此处省略77个文件信息
相关资源
- Jieba-Analysis 结巴分词
- 科大讯飞语音识别java版本demo
- 百度语音识别DEMO
- 百度语音识别android集成(eclipse)
- android开发讯飞离线命令词识别demo
- Unity 接入讯飞语音识别包(Android)
- 科大讯飞语音识别
- Android 语音发短信(语音识别-11_100)
- 讯飞语音识别android studio最简单的
- Android 实现语音识别的完整代码
- Sunflower.jar
- Android 语音唤醒(语音识别-11_101)
- Android 语音电子书(语音识别-11_099)
- Android 会聊天的机器人(语音识别-1
- Android平台使用PocketSphinx做离线语音识
- android 语音识别 合成听写 (科大讯飞
- android 语音识别
- android 语音识别可用(科大讯飞)
- 百度语音识别
- Android 语音识别
- 语音机器人(百度语音识别)
- Android根据文字语音播报、语音识别成
- Android高级应用源码-Android平台使用P
- 基于科大讯飞语音识别语音合成
- 语音识别:微信小程序开发(科大讯
- Android 语音识别 (语音转文字)
- Android 语音打电话(语音识别-11_098)
- 语音识别转文字(基于科大讯飞)
- android 语音识别转文字
评论
共有 条评论