Skip to content

Commit

Permalink
Revert "add a display name param for now. Should a structure be used …
Browse files Browse the repository at this point in the history
…here?"

This reverts commit 1070419.
  • Loading branch information
dave-gray101 committed Oct 22, 2024
1 parent 1070419 commit dee6ea0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 16 deletions.
7 changes: 1 addition & 6 deletions core/backend/soundgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func SoundGeneration(
doSample *bool,
sourceFile *string,
sourceDivisor *int32,
displayModelName string,
loader *model.ModelLoader,
appConfig *config.ApplicationConfig,
backendConfig config.BackendConfig,
Expand All @@ -40,16 +39,12 @@ func SoundGeneration(
return "", nil, fmt.Errorf("failed creating audio directory: %s", err)
}

if displayModelName == "" {
displayModelName = backendConfig.Model
}

fileName := utils.GenerateUniqueFileName(appConfig.AudioDir, "sound_generation", ".wav")
filePath := filepath.Join(appConfig.AudioDir, fileName)

res, err := soundGenModel.SoundGeneration(context.Background(), &proto.SoundGenerationRequest{
Text: text,
Model: displayModelName,
Model: backendConfig.Model,
Dst: filePath,
Sample: doSample,
Duration: duration,
Expand Down
8 changes: 3 additions & 5 deletions core/backend/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"

"github.com/mudler/LocalAI/core/config"
"github.com/rs/zerolog/log"

"github.com/mudler/LocalAI/pkg/grpc/proto"
"github.com/mudler/LocalAI/pkg/model"
Expand All @@ -17,7 +18,6 @@ func ModelTTS(
text,
voice,
language string,
displayModelName string,
loader *model.ModelLoader,
appConfig *config.ApplicationConfig,
backendConfig config.BackendConfig,
Expand All @@ -38,16 +38,14 @@ func ModelTTS(
return "", nil, fmt.Errorf("failed creating audio directory: %s", err)
}

if displayModelName == "" {
displayModelName = backendConfig.Model
}
log.Warn().Str("config.Model", backendConfig.Model).Str("config.Backend", backendConfig.Backend).Msg("ModelTTS before call to backend (ttsModel.TTS)")

fileName := utils.GenerateUniqueFileName(appConfig.AudioDir, "tts", ".wav")
filePath := filepath.Join(appConfig.AudioDir, fileName)

res, err := ttsModel.TTS(context.Background(), &proto.TTSRequest{
Text: text,
Model: displayModelName,
Model: backendConfig.Model,
Voice: voice,
Dst: filePath,
Language: &language,
Expand Down
2 changes: 1 addition & 1 deletion core/cli/soundgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (t *SoundGenerationCMD) Run(ctx *cliContext.Context) error {

filePath, _, err := backend.SoundGeneration(text,
parseToFloat32Ptr(t.Duration), parseToFloat32Ptr(t.Temperature), &t.DoSample,
inputFile, parseToInt32Ptr(t.InputFileSampleDivisor), "", ml, opts, options)
inputFile, parseToInt32Ptr(t.InputFileSampleDivisor), ml, opts, options)

if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion core/cli/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (t *TTSCMD) Run(ctx *cliContext.Context) error {
options.Backend = t.Backend
options.Model = t.Model

filePath, _, err := backend.ModelTTS(text, t.Voice, t.Language, "", ml, opts, options)
filePath, _, err := backend.ModelTTS(text, t.Voice, t.Language, ml, opts, options)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion core/http/endpoints/elevenlabs/soundgeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func SoundGenerationEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoad
log.Debug().Str("modelFile", "modelFile").Str("backend", cfg.Backend).Msg("Sound Generation Request about to be sent to backend")

// TODO: Support uploading files?
filePath, _, err := backend.SoundGeneration(input.Text, input.Duration, input.Temperature, input.DoSample, nil, nil, input.ModelID, ml, appConfig, *cfg)
filePath, _, err := backend.SoundGeneration(input.Text, input.Duration, input.Temperature, input.DoSample, nil, nil, ml, appConfig, *cfg)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion core/http/endpoints/elevenlabs/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TTSEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfi

log.Debug().Str("modelName", input.ModelID).Msg("elevenlabs TTS request recieved")

filePath, _, err := backend.ModelTTS(input.Text, voiceID, input.LanguageCode, input.ModelID, ml, appConfig, *cfg)
filePath, _, err := backend.ModelTTS(input.Text, voiceID, input.LanguageCode, ml, appConfig, *cfg)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion core/http/endpoints/localai/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TTSEndpoint(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfi
cfg.Voice = input.Voice
}

filePath, _, err := backend.ModelTTS(input.Input, cfg.Voice, cfg.Language, input.Model, ml, appConfig, *cfg)
filePath, _, err := backend.ModelTTS(input.Input, cfg.Voice, cfg.Language, ml, appConfig, *cfg)
if err != nil {
return err
}
Expand Down

0 comments on commit dee6ea0

Please sign in to comment.