Skip to content

Go调用websocket接口离线转写会提前中断websocket连接 #2834

@ibarryyan

Description

@ibarryyan

使用的是仓库提供的代码样例:
https://github.com/modelscope/FunASR/blob/main/runtime/golang/websocket/go_ws_client.go

在这一行(第326行)中有这样的逻辑:

if meg.Mode == "offline" {
	if timestamp != "" {
		text_print += fmt.Sprintf("%s timestamp: %s", text, timestamp)
	} else {
		text_print += fmt.Sprintf("%s ", text)
	}
	fmt.Println("\rpid" + id + ": " + wav_name + ": " + text_print)
	offline_msg_done = true
}

但是在websocket的返回结果中每个meg的Mode值都是offline,这就会导致websocket接口提前关闭连接,进而引发中断,文件没处理完就提前中止了

针对这个问题目前我的解决办法是不主动关闭websocket连接,设置定时器假设为30秒,如果websocket接口持续30秒不返回数据默认就是处理结束,除了这个办法以外大家还有什么好办法吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions