-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
994 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>run.mone</groupId> | ||
<artifactId>ai</artifactId> | ||
<version>1.4-jdk20-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>bytedance</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.java-websocket</groupId> | ||
<artifactId>Java-WebSocket</artifactId> | ||
<version>1.5.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.12.4</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
40 changes: 40 additions & 0 deletions
40
jcommon/ai/bytedance/src/main/java/run/mone/ai/bytedance/ArsClientOut.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package run.mone.ai.bytedance; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.util.Arrays; | ||
|
||
@Slf4j | ||
public class ArsClientOut { | ||
|
||
public static String callArsClient(ArsRequest request) { | ||
String response = ""; | ||
AsrClient asr_client = null; | ||
try { | ||
asr_client = AsrClient.build(); | ||
asr_client.setAppid(request.getAppId()); | ||
asr_client.setToken(request.getToken()); | ||
asr_client.setCluster(request.getCluster()); | ||
asr_client.setFormat(request.getAudio_format()); | ||
asr_client.setShow_utterances(true); | ||
asr_client.asr_sync_connect(); | ||
|
||
AsrResponse asr_response = asr_response = asr_client.asr_send(request.getAudio(), true); | ||
|
||
// get asr text | ||
// AsrResponse response = asr_client.getAsrResponse(); | ||
for (AsrResponse.Result result: asr_response.getResult()) { | ||
response = response + result.getText(); | ||
} | ||
} catch (Exception e) { | ||
log.error("callArsClient error", e); | ||
} finally { | ||
if (asr_client != null) { | ||
asr_client.asr_close(); | ||
} | ||
} | ||
return response; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
jcommon/ai/bytedance/src/main/java/run/mone/ai/bytedance/ArsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package run.mone.ai.bytedance; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ArsRequest { | ||
|
||
private String appId; | ||
|
||
private String token; | ||
|
||
private String cluster; | ||
|
||
@Builder.Default | ||
private String audio_format = "mp3"; | ||
|
||
private byte[] audio; | ||
} |
Oops, something went wrong.