You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
package echomeet
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
"yunyan/utils"
|
|
)
|
|
|
|
// @Summary 处理阿里云录音文件转写回调
|
|
// @Description 接收阿里云录音文件转写异步回调结果
|
|
// @Tags Echomeet
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param notify body pb.EchomeetAliCallbackReq true "阿里云回调参数"
|
|
// @Success 200 {object} comm.HttpResult{data=pb.EchomeetAliCallbackResp} "处理结果"
|
|
// @Router /api/home/echomeet_alibackcall [post]
|
|
func (this *apiComp) AliBackCall(session comm.IUserSession, req *pb.EchomeetAliCallbackReq) (resp *pb.EchomeetAliCallbackResp, errdata *pb.ErrorData) {
|
|
model, err := this.module.model.getrecordByTaskId(req.TaskId)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
// 抢收尾权,理由同 BackCall:回调重放 / 与轮询撞车 / 迟到的失败回调把已完成的
|
|
// 记录打回「转写失败」,三种都在这里挡掉。挡掉也回成功,不让阿里重投。
|
|
if !this.module.tasks.beginTranscribeFinish(model) {
|
|
this.module.Infof("AliBackCall id:%d 状态已是 %s 或收尾进行中,忽略本次回调",
|
|
model.Id, model.State.String())
|
|
resp = &pb.EchomeetAliCallbackResp{}
|
|
return
|
|
}
|
|
defer this.module.tasks.endTranscribeFinish(model.Id)
|
|
|
|
// 21050001 = 成功
|
|
if req.StatusCode != 21050001 {
|
|
model.State = pb.DBEchoMeetRecordState_TranscribeFail
|
|
this.module.model.refundRecordCompute(model, "阿里回调转写失败")
|
|
this.module.model.saverecord(model)
|
|
resp = &pb.EchomeetAliCallbackResp{}
|
|
return
|
|
}
|
|
|
|
contexts := make([]*pb.ContextStruct, 0)
|
|
if req.Result != nil {
|
|
for _, s := range req.Result.Sentences {
|
|
contexts = append(contexts, &pb.ContextStruct{
|
|
Content: s.Text,
|
|
Starttime: s.BeginTime,
|
|
Endtime: s.EndTime,
|
|
Speaker: s.SpeakerId, // 原始编号,格式化交给 normalizeSpeakers
|
|
})
|
|
}
|
|
}
|
|
// 同 BackCall:标签与 Personnel 统一走 normalizeSpeakers
|
|
normalizeSpeakers(model, contexts)
|
|
model.Original = utils.ToString(contexts)
|
|
model.State = pb.DBEchoMeetRecordState_AwaitSummarizing
|
|
this.module.tasks.TranslateProcess(model, contexts)
|
|
this.module.model.saverecord(model)
|
|
_ = this.module.tasks.submitAITaskOnce(model)
|
|
|
|
resp = &pb.EchomeetAliCallbackResp{}
|
|
return
|
|
}
|
|
|