diff --git a/api-spring-boot-starter/src/main/java/com/luna/api/xfyun/ocr/UniversalCharacterRecognitionApi.java b/api-spring-boot-starter/src/main/java/com/luna/api/xfyun/ocr/UniversalCharacterRecognitionApi.java index 45f388a0..540e877d 100644 --- a/api-spring-boot-starter/src/main/java/com/luna/api/xfyun/ocr/UniversalCharacterRecognitionApi.java +++ b/api-spring-boot-starter/src/main/java/com/luna/api/xfyun/ocr/UniversalCharacterRecognitionApi.java @@ -42,19 +42,23 @@ public class UniversalCharacterRecognitionApi { @SneakyThrows public static void main(String[] args) { - String s = getOcrText(XfConstant.REQUEST_URL, XfConstant.API_SECRET, XfConstant.API_KEY, IMAGE_PATH); + // java -jar /Users/weidian/compose/git/bfg-1.13.0.jar --delete-files e76d7d8f .git + // APPId = "e76d7d8f" # 控制台获取 + // APISecret = "Y2Y2ODc2OGQyOWFjMWZhY2JkOTllMDVl" # 控制台获取 + // APIKey = "990e2770b030441fbcc126c691daf5cd" # 控制台获取 + String s = getOcrText("e76d7d8f", "Y2Y2ODc2OGQyOWFjMWZhY2JkOTllMDVl", "990e2770b030441fbcc126c691daf5cd", IMAGE_PATH); System.out.println(s); OcrTextDTO parse = parse(s); System.out.println(JSON.toJSONString(getContent(parse))); } public static List getContent(String filePath) { - return getContent(XfConstant.API_SECRET, XfConstant.API_KEY, filePath); + return getContent(XfConstant.APPID, XfConstant.API_SECRET, XfConstant.API_KEY, filePath); } - public static List getContent(String apiSecret, String apiKey, String filePath) { + public static List getContent(String appId, String apiSecret, String apiKey, String filePath) { Assert.notNull(filePath, "文件路径不能为空"); - String ocrText = getOcrText(XfConstant.API_SECRET, XfConstant.API_KEY, filePath); + String ocrText = getOcrText(appId, apiSecret, apiKey, filePath); if (StringUtils.isBlank(ocrText)) { return Collections.emptyList(); } @@ -111,13 +115,13 @@ public static OcrTextDTO parse(String data) { return JSON.parseObject(result, OcrTextDTO.class); } - private static String getOcrText(String apiSecret, String apiKey, String filePath) { - return getOcrText(XfConstant.REQUEST_URL, apiSecret, apiKey, filePath); + private static String getOcrText(String appId, String apiSecret, String apiKey, String filePath) { + return getOcrText(XfConstant.REQUEST_URL, appId, apiSecret, apiKey, filePath); } - private static String getOcrText(String requestUrl, String apiSecret, String apiKey, String filePath) { + private static String getOcrText(String requestUrl, String appId, String apiSecret, String apiKey, String filePath) { OcrRequest ocrRequest = new OcrRequest(); - ocrRequest.setHeader(new OcrRequest.Header(XfConstant.APPID, 3)); + ocrRequest.setHeader(new OcrRequest.Header(appId, 3)); ocrRequest.setParameter(new OcrRequest.Parameter(OcrRequest.Sf8e6aca1.getInstance())); ocrRequest.setPayload( new OcrRequest.Payload(OcrRequest.Sf8e6aca1DataOne.getInstance(Base64.getEncoder().encodeToString(FileTools.read(filePath))))); diff --git a/api-spring-boot-starter/src/main/resources/application-pro.yml b/api-spring-boot-starter/src/main/resources/application-pro.yml index 77b5634c..b417e6ae 100644 --- a/api-spring-boot-starter/src/main/resources/application-pro.yml +++ b/api-spring-boot-starter/src/main/resources/application-pro.yml @@ -8,9 +8,10 @@ spring: xunfei: enable: true - app-id: "5eae601b" - api-secret: "f8457806d8ae791dcfd250c1b4ca2ba8" - apikey: "d0b88051dff7906c15ab700316a2a412" + app-id: "e76d7d8f" + api-secret: "990e2770b030441fbcc126c691daf5cd" + apikey: "Y2Y2ODc2OGQyOWFjMWZhY2JkOTllMDVl" + mail: default-encoding: UTF-8 diff --git a/pom.xml b/pom.xml index d9e073fe..e9e33a41 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,17 @@ luna-common ${luna-common.veriosn} + + + com.tencentcloudapi + tencentcloud-speech-sdk-java + 1.0.46 + + + org.apache.httpcomponents.client5 + httpclient5 + ${httpclient-5.version} + org.springframework.boot spring-boot-dependencies @@ -86,6 +97,7 @@ luna-common ${luna-common.veriosn} + diff --git a/tencent-spring-boot-starter/pom.xml b/tencent-spring-boot-starter/pom.xml index d88b781f..376175d2 100644 --- a/tencent-spring-boot-starter/pom.xml +++ b/tencent-spring-boot-starter/pom.xml @@ -40,7 +40,6 @@ com.tencentcloudapi tencentcloud-speech-sdk-java - 1.0.23