xf实时语音转写
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.newyetai;
|
||||
|
||||
import com.newyetai.sdk.xf.config.XfProperties.XfAppProperties;
|
||||
import com.newyetai.sdk.xf.model.TranslateReq;
|
||||
import com.newyetai.sdk.xf.service.RtasrClientApp;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -47,9 +50,11 @@ public class SparkTest {
|
||||
static XfProperties xfProperties = XfProperties.builder()
|
||||
.iatHostUrl("https://iat-api.xfyun.cn/v2/iat")
|
||||
.ttsHostUrl("https://tts-api.xfyun.cn/v2/tts")
|
||||
.appId("a2847f13")
|
||||
.apiSecret("")
|
||||
.apiKey("")
|
||||
.otsHostUrl("https://ntrans.xfyun.cn/v2/ots")
|
||||
.appId("83b8ddca")
|
||||
.apiSecret("ZWE2MjkzY2VmZDkwM2EwZGJhNGRhOWJm")
|
||||
.apiKey("e092f93e28ebe6d27f756bb2d884dcff")
|
||||
.rtasr(XfAppProperties.builder().apiKey("2e33d9128a73be21b294594e5377ca53").build())
|
||||
.build();
|
||||
|
||||
@Test
|
||||
@@ -207,7 +212,7 @@ public class SparkTest {
|
||||
// WebTtsWS.execute("欢迎来到讯飞开放平台", xfProperties, outputStream);
|
||||
// fs.write(outputStream.toByteArray());
|
||||
// }
|
||||
|
||||
|
||||
try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
OutputStream fs = new FileOutputStream("src/main/resources/iat/323.mp3");){
|
||||
AlitaResult<Void> result = WebTtsWS.execute("欢迎来到讯飞开放平台", xfProperties, outputStream);
|
||||
@@ -218,4 +223,20 @@ public class SparkTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ots(){
|
||||
// AlitaResult<?> result = XfSparkProvider.translate(TranslateReq.builder().text("欢迎#你啊,.;@#$你好").build(), xfProperties);
|
||||
AlitaResult<?> result = XfSparkProvider.translate(TranslateReq.builder().text("تىيانەي ئەقىللىق خىزمەت مۇلازىمىتى بىرلەشمە سۇپىسىغا خوش ھەمرىيىڭىز.").from("uy").to("cn").build(), xfProperties);
|
||||
log.info("{}", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rtasr() throws IOException {
|
||||
String file = "src/main/resources/iat/ug.pcm";
|
||||
try (InputStream is = new FileInputStream(file)) {
|
||||
AlitaResult<String> result = RtasrClientApp.execute(is, "cn_uyghur", xfProperties);
|
||||
log.info("{}", result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user