标签:res string cas ace tst ack let ken stream
使用restTemplate获取语音文件,在线播放
public void getAudioTest(HttpServletRequest request, HttpServletResponse response) {
try {
response.setContentType("audio/wav;charset=UTF-8");
StringBuilder resultUrl = new StringBuilder();
String appId = "xinshen_ym_dae";
String taskResultId = "278878841";
String token = "pQ6tJwZ2z5z4d8rp";
long time = System.currentTimeMillis() / 1000;
String sign = Objects.requireNonNull(MD5Util.MD5(appId + time + token)).toLowerCase();
resultUrl.append("http://10.21.191.72:8988")
.append("/outCall/playRecord?sign=").append(sign)
.append("&time=").append(time)
.append("&appId=").append(appId)
.append("&relatedId=").append(taskResultId);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Resource> entity = restTemplate.getForEntity(resultUrl.toString(), Resource.class);
IOUtils.copy(entity.getBody().getInputStream(), response.getOutputStream());
response.flushBuffer();
}catch (Exception e){
e.printStackTrace();
}
}
标签:res string cas ace tst ack let ken stream
原文地址:https://www.cnblogs.com/StivenYang/p/13259832.html