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.
31 lines
718 B
31 lines
718 B
package localai
|
|
|
|
import (
|
|
"github.com/go-skynet/LocalAI/api/backend"
|
|
config "github.com/go-skynet/LocalAI/api/config"
|
|
|
|
"github.com/go-skynet/LocalAI/api/options"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type TTSRequest struct {
|
|
Model string `json:"model" yaml:"model"`
|
|
Input string `json:"input" yaml:"input"`
|
|
}
|
|
|
|
func TTSEndpoint(cm *config.ConfigLoader, o *options.Option) func(c *fiber.Ctx) error {
|
|
return func(c *fiber.Ctx) error {
|
|
|
|
input := new(TTSRequest)
|
|
// Get input data from the request body
|
|
if err := c.BodyParser(input); err != nil {
|
|
return err
|
|
}
|
|
|
|
filePath, _, err := backend.ModelTTS(input.Input, input.Model, o.Loader, o)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return c.Download(filePath)
|
|
}
|
|
}
|
|
|