Skip to content

Commit e9720c3

Browse files
committed
allow tts param definition in config file
- consolidate TTS options under `tts` config entry Signed-off-by: blob42 <[email protected]>
1 parent c5281dd commit e9720c3

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

core/config/backend_config.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ const (
2424
RAND_SEED = -1
2525
)
2626

27+
type TTSConfig struct {
28+
29+
// Voice wav path or id
30+
Voice string `yaml:"voice"`
31+
32+
// Vall-e-x
33+
VallE VallE `yaml:"vall-e"`
34+
}
35+
2736
type BackendConfig struct {
2837
schema.PredictionOptions `yaml:"parameters"`
2938
Name string `yaml:"name"`
@@ -56,8 +65,8 @@ type BackendConfig struct {
5665
// GRPC Options
5766
GRPC GRPC `yaml:"grpc"`
5867

59-
// Vall-e-x
60-
VallE VallE `yaml:"vall-e"`
68+
// TTS specifics
69+
TTSConfig `yaml:"tts"`
6170

6271
// CUDA
6372
// Explicitly enable CUDA or not (some backends might need it)
@@ -373,6 +382,7 @@ func (cl *BackendConfigLoader) LoadBackendConfigFileByName(modelName, modelPath
373382
if err := cl.LoadBackendConfig(
374383
modelConfig, opts...,
375384
); err != nil {
385+
log.Error().Msgf("failed loading model config (%s) %s", modelConfig, err.Error())
376386
return nil, fmt.Errorf("failed loading model config (%s) %s", modelConfig, err.Error())
377387
}
378388
cfgExisting, exists = cl.GetBackendConfig(modelName)

core/http/endpoints/localai/tts.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TTSEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfi
4343
)
4444

4545
if err != nil {
46+
log.Err(err)
4647
modelFile = input.Model
4748
log.Warn().Msgf("Model not found in context: %s", input.Model)
4849
} else {
@@ -54,7 +55,15 @@ func TTSEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfi
5455
cfg.Backend = input.Backend
5556
}
5657

57-
filePath, _, err := backend.ModelTTS(cfg.Backend, input.Input, modelFile, input.Voice, input.Language, ml, appConfig, *cfg)
58+
if input.Language != "" {
59+
cfg.Language = input.Language
60+
}
61+
62+
if input.Voice != "" {
63+
cfg.Voice = input.Voice
64+
}
65+
66+
filePath, _, err := backend.ModelTTS(cfg.Backend, input.Input, modelFile, cfg.Voice, cfg.Language, ml, appConfig, *cfg)
5867
if err != nil {
5968
return err
6069
}

0 commit comments

Comments
 (0)