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.
|
|
|
|
package web
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"goskeleton/app/global/consts"
|
|
|
|
|
"goskeleton/app/service/ai_model_cli"
|
|
|
|
|
"goskeleton/app/utils/response"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type AiRecognition struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ai 模型识别模块,与ai相关的识别功能,包括:图片文字识别、语音识别
|
|
|
|
|
//
|
|
|
|
|
// 图片文字识别
|
|
|
|
|
func (u *AiRecognition) PicRecognition(context *gin.Context) {
|
|
|
|
|
if r, recogWords := ai_model_cli.RequestOCR(context); r {
|
|
|
|
|
response.Success(context, consts.CurdStatusOkMsg, recogWords)
|
|
|
|
|
} else {
|
|
|
|
|
response.Fail(context, consts.PicRecognitionFailCode, consts.PicRecognitionFailMsg, "")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 语音文字识别
|
|
|
|
|
func (u *AiRecognition) VocRecognition(context *gin.Context) {
|
|
|
|
|
if r, recogWords := ai_model_cli.RequestVOP(context); r {
|
|
|
|
|
response.Success(context, consts.CurdStatusOkMsg, recogWords)
|
|
|
|
|
} else {
|
|
|
|
|
response.Fail(context, consts.VocRecognitionFailCode, consts.VocRecognitionFailMsg, "")
|
|
|
|
|
}
|
|
|
|
|
}
|