本文主要是介绍spring boot 调用青柿流媒体喊话接口,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
技术交流QQ群
933925017
livegbs接口 https://gbs.liveqing.com:10010/apidoc/#api-control-ControlTalk
喊话流程是每次取4000个字符然后进行base64encoding–>urlencode
官方给的图片
是用的golang写的
2.java实现
/*** 青柿语音喊话*/public Boolean liveGBSShout(String file, String serial, Integer channel) {byte[] bytes = getBytes(file);int length = bytes.length;int step = 4000;String base64Data = null;Boolean flag = true;for (int i = 0; i <= length; i = i + step) {if ((i + step) > length) {byte[] subBytes = subBytes(bytes, i, length - i);base64Data = Base64.getEncoder().encodeToString(subBytes);} else {byte[] subBytes = subBytes(bytes, i, step);base64Data = Base64.getEncoder().encodeToString(subBytes);}try {String encode = URLEncoder.encode(base64Data, "utf-8");String url = "https://channel2.cspid.cn/api/v1/control/talk?serial=" + serial + "&channel=" + channel + "&audio=" + encode;String get = HttpClientUtils.doGet(url);} catch (Exception e) {e.printStackTrace();flag = false;}}return flag;}// 拷贝byte数组public static byte[] subBytes(byte[] src, int begin, int length) {byte[] bytes = new byte[length];System.arraycopy(src, begin, bytes, 0, length);return bytes;}
这篇关于spring boot 调用青柿流媒体喊话接口的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!