MCPcopy Index your code
hub / github.com/modelscope/FunASR / sendJson

Method sendJson

runtime/java/FunasrWsClient.java:68–129  ·  view source on GitHub ↗
(
      String mode, String strChunkSize, int chunkInterval, String wavName, boolean isSpeaking,String suffix)

Source from the content-addressed store, hash-verified

66
67 // send json at first time
68 public void sendJson(
69 String mode, String strChunkSize, int chunkInterval, String wavName, boolean isSpeaking,String suffix) {
70 try {
71
72 JSONObject obj = new JSONObject();
73 obj.put("mode", mode);
74 JSONArray array = new JSONArray();
75 String[] chunkList = strChunkSize.split(",");
76 for (int i = 0; i < chunkList.length; i++) {
77 array.add(Integer.valueOf(chunkList[i].trim()));
78 }
79
80 obj.put("chunk_size", array);
81 obj.put("chunk_interval", new Integer(chunkInterval));
82 obj.put("wav_name", wavName);
83
84 if(FunasrWsClient.hotwords.trim().length()>0)
85 {
86 String regex = "\\d+";
87 JSONObject jsonitems = new JSONObject();
88 String[] items=FunasrWsClient.hotwords.trim().split(" ");
89 Pattern pattern = Pattern.compile(regex);
90 String tmpWords="";
91 for(int i=0;i<items.length;i++)
92 {
93
94 Matcher matcher = pattern.matcher(items[i]);
95
96 if (matcher.matches()) {
97
98 jsonitems.put(tmpWords.trim(), items[i].trim());
99 tmpWords="";
100 continue;
101 }
102 tmpWords=tmpWords+items[i]+" ";
103
104 }
105
106
107
108 obj.put("hotwords", jsonitems.toString());
109 }
110
111 if(suffix.equals("wav")){
112 suffix="pcm";
113 }
114 obj.put("wav_format", suffix);
115 if (isSpeaking) {
116 obj.put("is_speaking", new Boolean(true));
117 } else {
118 obj.put("is_speaking", new Boolean(false));
119 }
120 logger.info("sendJson: " + obj);
121 // return;
122
123 send(obj.toString());
124
125 return;

Callers 1

recWavMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected