From a4833f38c41c9c5998f45db7b0884e10498605ec Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期日, 20 八月 2023 17:35:58 +0800
Subject: [PATCH] Merge branch 'main' of https://github.com/alibaba-damo-academy/FunASR into main
---
funasr/runtime/html5/static/wsconnecter.js | 5 +++++
funasr/runtime/docs/docker_offline_cpu_zh_lists | 2 --
funasr/runtime/java/FunasrWsClient.java | 13 ++++++++++---
funasr/runtime/html5/static/main.js | 5 +++++
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/funasr/runtime/docs/docker_offline_cpu_zh_lists b/funasr/runtime/docs/docker_offline_cpu_zh_lists
index ddce7a0..6742f73 100644
--- a/funasr/runtime/docs/docker_offline_cpu_zh_lists
+++ b/funasr/runtime/docs/docker_offline_cpu_zh_lists
@@ -2,8 +2,6 @@
funasr-runtime-sdk-cpu-0.1.0
DEFAULT_ASR_MODEL:
damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx
- damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx
- damo/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404-onnx
DEFAULT_VAD_MODEL:
damo/speech_fsmn_vad_zh-cn-16k-common-onnx
DEFAULT_PUNC_MODEL:
diff --git a/funasr/runtime/html5/static/main.js b/funasr/runtime/html5/static/main.js
index f8d3bfd..7e3573d 100644
--- a/funasr/runtime/html5/static/main.js
+++ b/funasr/runtime/html5/static/main.js
@@ -44,6 +44,7 @@
var isfilemode=false; // if it is in file mode
+var file_ext="";
var file_data_array; // array to save file data
var totalsend=0;
@@ -81,6 +82,10 @@
for(let i = 0; i < len; i++) {
let fileAudio = new FileReader();
fileAudio.readAsArrayBuffer(this.files[i]);
+ file_ext=this.files[i].name.split('.').pop().toLowerCase();
+ if(file_ext==="wav"){
+ file_ext="pcm";
+ }
fileAudio.onload = function() {
var audioblob= fileAudio.result;
file_data_array=audioblob;
diff --git a/funasr/runtime/html5/static/wsconnecter.js b/funasr/runtime/html5/static/wsconnecter.js
index 2873022..4beec83 100644
--- a/funasr/runtime/html5/static/wsconnecter.js
+++ b/funasr/runtime/html5/static/wsconnecter.js
@@ -72,7 +72,12 @@
"is_speaking": true,
"chunk_interval":10,
"mode":getAsrMode(),
+
};
+ if(isfilemode)
+ {
+ request.wav_format=file_ext;
+ }
console.log(request);
speechSokt.send( JSON.stringify(request) );
console.log("杩炴帴鎴愬姛");
diff --git a/funasr/runtime/java/FunasrWsClient.java b/funasr/runtime/java/FunasrWsClient.java
index eba85bb..43407f3 100644
--- a/funasr/runtime/java/FunasrWsClient.java
+++ b/funasr/runtime/java/FunasrWsClient.java
@@ -50,7 +50,8 @@
}
public FunasrWsClient(URI serverURI) {
- super(serverURI);
+
+ super(serverURI);
}
public FunasrWsClient(URI serverUri, Map<String, String> httpHeaders) {
@@ -64,7 +65,7 @@
// send json at first time
public void sendJson(
- String mode, String strChunkSize, int chunkInterval, String wavName, boolean isSpeaking) {
+ String mode, String strChunkSize, int chunkInterval, String wavName, boolean isSpeaking,String suffix) {
try {
JSONObject obj = new JSONObject();
@@ -78,6 +79,10 @@
obj.put("chunk_size", array);
obj.put("chunk_interval", new Integer(chunkInterval));
obj.put("wav_name", wavName);
+ if(suffix.equals("wav")){
+ suffix="pcm";
+ }
+ obj.put("wav_format", suffix);
if (isSpeaking) {
obj.put("is_speaking", new Boolean(true));
} else {
@@ -114,7 +119,9 @@
// function for rec wav file
public void recWav() {
- sendJson(mode, strChunkSize, chunkInterval, wavName, true);
+ String fileName=FunasrWsClient.wavPath;
+ String suffix=fileName.split("\\.")[fileName.split("\\.").length-1];
+ sendJson(mode, strChunkSize, chunkInterval, wavName, true,suffix);
File file = new File(FunasrWsClient.wavPath);
int chunkSize = sendChunkSize;
--
Gitblit v1.9.1