Skip to content

Commit

Permalink
Merge pull request #28 from lunasaw/3.2.0-SNAPSHOT
Browse files Browse the repository at this point in the history
3.2.0 snapshot
  • Loading branch information
lunasaw authored Jun 24, 2024
2 parents 482dc05 + 7420301 commit b06e58b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> getContent(String apiSecret, String apiKey, String filePath) {
public static List<String> 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();
}
Expand Down Expand Up @@ -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)))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@
<artifactId>luna-common</artifactId>
<version>${luna-common.veriosn}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.tencentcloudapi/tencentcloud-speech-sdk-java -->
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-speech-sdk-java</artifactId>
<version>1.0.46</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpclient-5.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
Expand Down Expand Up @@ -86,6 +97,7 @@
<artifactId>luna-common</artifactId>
<version>${luna-common.veriosn}</version>
</dependency>

</dependencies>

<distributionManagement>
Expand Down
1 change: 0 additions & 1 deletion tencent-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-speech-sdk-java</artifactId>
<version>1.0.23</version>
</dependency>
</dependencies>

Expand Down

0 comments on commit b06e58b

Please sign in to comment.