资源简介
有前端代码,后端代码,有jar包【代码都是能运行的,自己搭建一下前后端访问】有问题请留言,百分一百搭建成功可以运行
代码片段和文件信息
/*
* Copyright (c) 2017-2018 THL A29 Limited a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.szt.tjpt.util.voice;
import com.tencent.cloud.asr.realtime.sdk.config.AsrbaseConfig;
import com.tencent.cloud.asr.realtime.sdk.config.AsrGlobelConfig;
import com.tencent.cloud.asr.realtime.sdk.config.AsrInternalConfig;
import com.tencent.cloud.asr.realtime.sdk.config.AsrPersonalConfig;
import com.tencent.cloud.asr.realtime.sdk.http.synchronize.RequestSender;
import com.tencent.cloud.asr.realtime.sdk.model.enums.ResponseEncode;
import com.tencent.cloud.asr.realtime.sdk.model.enums.SdkRole;
import com.tencent.cloud.asr.realtime.sdk.model.enums.VoiceFormat;
import com.tencent.cloud.asr.realtime.sdk.model.response.VadResponse;
import com.tencent.cloud.asr.realtime.sdk.model.response.VoiceResponse;
import com.tencent.cloud.asr.realtime.sdk.utils.ByteUtils;
import com.tencent.cloud.asr.realtime.sdk.utils.JacksonUtil;
import java.io.InputStream;
//import com.tencent.cloud.asr.realtime.sdk.config.AsrGlobelConfig;
/**
* 同步调用实例。发一个请求,收到一个回复。回复收到之前,会一直阻塞。
*
* @author iantang
* @version 1.0
*/
public class RasrRequestSample {
static {
initbaseParameters();
}
public static void main(String[] args) {
RasrRequestSample rasrRequestSample = new RasrRequestSample();
rasrRequestSample.start();
}
private void start() {
this.sendBytesRequest();
// this.sleepSomeTime();
// this.sendFileRequest();
// this.sleepSomeTime();
System.exit(0);
}
/**
* 从字节数组读取语音数据,发送请求。
*/
private void sendBytesRequest() {
RequestSender requestSender = new RequestSender();
byte[] content = ByteUtils.inputStream2ByteArray(“C:\\Users\\Administrator\\Desktop\\123\\17.wav“);
VoiceResponse voiceResponse = requestSender.sendFromBytes(content);
printReponse(voiceResponse);
}
/**
* 从字节数组读取语音数据,发送请求。
*/
public String sendBytesRequest(InputStream inputStream) {
String context = ““;
byte[] content = ByteUtils.toByteArray(inputStream);
RequestSender requestSender = new RequestSender();
VoiceResponse voiceResponse = requestSender.sendFromBytes(content);
//printReponse(voiceResponse);
if (voiceResponse != null && voiceResponse.getOriginalText()!=null && !voiceResponse.getOriginalText().equals(““)){
VadResponse vadResponse = JacksonUtil.parse(voiceResponse.getOriginalText()VadResponse.class);
if(vadResponse.getResultList()!=null && vadResponse.getResultList().size()>0){
String te
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-06-15 15:26 腾讯实时语音转化文字\
文件 5918 2020-06-15 14:45 腾讯实时语音转化文字\RasrRequestSample.java
目录 0 2020-06-15 15:25 腾讯实时语音转化文字\js\
文件 482959 2020-06-13 11:51 腾讯实时语音转化文字\js\mp3-engine.js
文件 12092 2020-06-13 11:51 腾讯实时语音转化文字\js\mp3.js
文件 28409 2020-06-13 11:51 腾讯实时语音转化文字\js\recorder-core.js
文件 2368 2020-06-13 11:51 腾讯实时语音转化文字\js\wav.js
文件 4371738 2020-06-13 18:40 腾讯实时语音转化文字\vocie-1.0.jar
文件 5830 2020-06-15 14:15 腾讯实时语音转化文字\voiceText.js
目录 0 2020-06-15 15:26 腾讯实时语音转化文字\后台接口\
文件 1573 2020-06-15 15:27 腾讯实时语音转化文字\后台接口\StatisticalController.java
评论
共有 条评论