package handler import ( "git.links123.net/links123.com/pkg/request" "git.links123.net/Slate/CorpusAI/service" "git.links123.net/Slate/CorpusAI/service/api" "github.com/Unknwon/i18n" "github.com/gin-gonic/gin" "errors" "git.links123.net/Slate/CorpusAI/config" ) func Healthy(ctx *gin.Context) { cp := &api.CommonParams{} if request.ParseParamFail(ctx, cp) { return } request.Success(ctx, gin.H{"msg": i18n.Tr(cp.TargetStr, "hi", "Paul")}) } // TextToSpeech godoc // @Tags 语料库 // @Summary 获取音频接口base url // @Description 获取音频接口base url(主要用于海内外接口地址分开) // @Accept json // @Produce json // @Param ip query string false "IP地址, 默认无需传, 自动获取" // @Success 200 {string} json "{"audio_base_url": "https://campusai.links123.com/v1/en/tts","country_code": "国家code","ip": "ip地址"}" // @Failure 400 {string} json "{"msg": "error info"}" // @Failure 500 {string} json "{"msg": "error info"}" // @Router /en/audio_base_url [get] func GetAudioBaseUrl(ctx *gin.Context) { ip := ctx.DefaultQuery("ip", ctx.ClientIP()) if ip == "" { request.Fail(ctx, 400, errors.New("client ip error")) return } countryCode := service.Ip2Country(ip) appConfig := config.C.App baseUrl := appConfig.CNHost + "/v1/en/tts" if countryCode!="" && countryCode != "CN" { baseUrl = appConfig.HKHost + "/v1/en/tts" } request.Success(ctx, gin.H{"audio_base_url": baseUrl,"country_code":countryCode,"ip":ip}) }