12345678910111213141516171819202122232425262728293031323334353637 |
- package handler
-
- import (
- "net/http"
- "git.links123.net/links123.com/pkg/request"
- "git.links123.net/Slate/CorpusAI/service"
- "github.com/gin-gonic/gin"
- )
- // SpeechToText godoc
- // @Tags 语料库
- // @Summary 语音转文本
- // @Description speech to Text
- // @Accept json
- // @Produce json
- // @Param file query file true "发音文件"
- // @Param language path string false "语言,en英文,zh中文,默认英文"
- // @Param rate path int false "码率,8/16 默认16"
- // @Success 200 {string} string "test"
- // @Failure 400 {string} json "{"msg": "error info"}"
- // @Failure 500 {string} json "{"msg": "error info"}"
- // @Router /en/stt [post]
- func SpeechToText(ctx *gin.Context){
- file, _, err := ctx.Request.FormFile("file")
- if request.Fail(ctx,http.StatusBadRequest,err){
- return
- }
-
- lang,_ := ctx.GetQuery("language")
- rateStr,_ := ctx.GetQuery("rate")
-
- ret, err := service.SpeechToText(file,lang,rateStr)
- if request.Fail(ctx,http.StatusInternalServerError,err) {
- return
- }
-
- request.Success(ctx,ret)
- }
|