2023-10-03 22:09:38 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/labstack/echo/v4"
|
2023-10-05 20:31:16 +00:00
|
|
|
"github.com/labstack/echo/v4/middleware"
|
2023-10-03 22:09:38 +00:00
|
|
|
"github.com/labstack/gommon/log"
|
2023-10-05 18:05:30 +00:00
|
|
|
"github.com/xzeldon/whisper-api-server/internal/api"
|
|
|
|
"github.com/xzeldon/whisper-api-server/internal/resources"
|
2023-10-03 22:09:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
e := echo.New()
|
|
|
|
e.HideBanner = true
|
|
|
|
|
2023-10-05 20:31:16 +00:00
|
|
|
e.Use(middleware.CORS())
|
|
|
|
|
2023-10-03 22:09:38 +00:00
|
|
|
if l, ok := e.Logger.(*log.Logger); ok {
|
|
|
|
l.SetHeader("${time_rfc3339} ${level}")
|
|
|
|
}
|
|
|
|
|
2023-10-05 18:05:30 +00:00
|
|
|
_, err := resources.GetWhisperDll("1.12.0")
|
|
|
|
if err != nil {
|
|
|
|
e.Logger.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
model, err := resources.GetModel("ggml-medium.bin")
|
|
|
|
if err != nil {
|
|
|
|
e.Logger.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
whisperState, err := api.InitializeWhisperState(model)
|
2023-10-03 22:09:38 +00:00
|
|
|
if err != nil {
|
|
|
|
e.Logger.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
e.POST("/v1/audio/transcriptions", func(c echo.Context) error {
|
2023-10-05 18:05:30 +00:00
|
|
|
return api.Transcribe(c, whisperState)
|
2023-10-03 22:09:38 +00:00
|
|
|
})
|
|
|
|
|
2023-10-05 18:05:30 +00:00
|
|
|
e.Logger.Fatal(e.Start("127.0.0.1:3000"))
|
2023-10-03 22:09:38 +00:00
|
|
|
}
|