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

Method onMessage

runtime/java/FunasrWsClient.java:209–231  ·  view source on GitHub ↗
(String message)

Source from the content-addressed store, hash-verified

207 }
208
209 @Override
210 public void onMessage(String message) {
211 JSONObject jsonObject = new JSONObject();
212 JSONParser jsonParser = new JSONParser();
213 logger.info("received: " + message);
214 try {
215 jsonObject = (JSONObject) jsonParser.parse(message);
216 logger.info("text: " + jsonObject.get("text"));
217 if(jsonObject.containsKey("timestamp"))
218 {
219 logger.info("timestamp: " + jsonObject.get("timestamp"));
220 }
221 } catch (org.json.simple.parser.ParseException e) {
222 e.printStackTrace();
223 }
224 if (iseof && mode.equals("offline") && !jsonObject.containsKey("is_final")) {
225 close();
226 }
227
228 if (iseof && mode.equals("offline") && jsonObject.containsKey("is_final") && jsonObject.get("is_final").equals("false")) {
229 close();
230 }
231 }
232
233 @Override
234 public void onClose(int code, String reason, boolean remote) {

Callers

nothing calls this directly

Calls 2

parseMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected