diff --git a/.gitignore b/.gitignore index c342109..0cda3e5 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ # Do not touch the flowing 3 lines config.yaml talk.yaml -google_credentials.json +google-service-account-key.json # Go workspace file go.work diff --git a/configs/talk.sample.yaml b/configs/talk.sample.yaml index 1fc585e..39c27e6 100644 --- a/configs/talk.sample.yaml +++ b/configs/talk.sample.yaml @@ -29,7 +29,7 @@ text-to-speech: clarity: 0.5 google-text-to-speech: # Download a key file from Google Cloud. see https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-console - path-to-keyfile: ./google_credentials.json + path-to-service-account-key-file: ./google-service-account-key.json # Optional. Use en-US if not specified. Choose a language-code from https://www.rfc-editor.org/rfc/bcp/bcp47.txt language-code: en-US # Optional. Use this voice whenever available, or randomly select a voice from the voice list diff --git a/internal/config/config.go b/internal/config/config.go index e541c55..b3c65b3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -34,13 +34,13 @@ type ElevenLabsConfig struct { } type GoogleTextTOSpeechConfig struct { - PathToKeyfile string `mapstructure:"path-to-keyfile"` - LanguageCode string `mapstructure:"language-code"` - VoiceID string `mapstructure:"voice-id"` - Gender string `mapstructure:"gender"` - SpeakingRate float32 `mapstructure:"speaking-rate"` - Pitch float32 `mapstructure:"pitch"` - VolumeGainDb float32 `mapstructure:"volume-gain-db"` + PathToServiceAccountKeyFile string `mapstructure:"path-to-service-account-key-file"` + LanguageCode string `mapstructure:"language-code"` + VoiceID string `mapstructure:"voice-id"` + Gender string `mapstructure:"gender"` + SpeakingRate float32 `mapstructure:"speaking-rate"` + Pitch float32 `mapstructure:"pitch"` + VolumeGainDb float32 `mapstructure:"volume-gain-db"` } type LlmConfig struct { diff --git a/internal/config/parse.go b/internal/config/parse.go index 59df5bc..7127aa5 100644 --- a/internal/config/parse.go +++ b/internal/config/parse.go @@ -8,18 +8,18 @@ import ( ) const ( - DefaultServerPort = 8000 - DefaultServerEagerCheckProviders = true - DefaultElevenLabsStability = 0.5 - DefaultElevenLabsClarity = 0.5 - DefaultGoogleTTSPathToKeyfile = "./google_credentials.json" - DefaultGoogleTTSLanguageCode = "en-US" - DefaultGoogleTTSGender = "female" - DefaultGoogleTTSSpeakingRate = 1 - DefaultGoogleTTSPitch = 0 - DefaultGoogleTTSVolumeGainDb = 0 - DefaultChatGPTModel = "gpt-3.5-turbo" - DefaultChatGPTMaxGenerationToken = 2000 + DefaultServerPort = 8000 + DefaultServerEagerCheckProviders = true + DefaultElevenLabsStability = 0.5 + DefaultElevenLabsClarity = 0.5 + DefaultGoogleTTSPathToServiceAccountKeyFile = "./google-service-account-key.json" + DefaultGoogleTTSLanguageCode = "en-US" + DefaultGoogleTTSGender = "female" + DefaultGoogleTTSSpeakingRate = 1 + DefaultGoogleTTSPitch = 0 + DefaultGoogleTTSVolumeGainDb = 0 + DefaultChatGPTModel = "gpt-3.5-turbo" + DefaultChatGPTMaxGenerationToken = 2000 ) func setDefaultValue() { @@ -29,7 +29,7 @@ func setDefaultValue() { viper.SetDefault("text-to-speech.elevenlabs.stability", DefaultElevenLabsStability) viper.SetDefault("text-to-speech.elevenlabs.clarity", DefaultElevenLabsClarity) - viper.SetDefault("text-to-speech.google-text-to-speech.path-to-keyfile", DefaultGoogleTTSPathToKeyfile) + viper.SetDefault("text-to-speech.google-text-to-speech.path-to-service-account-key-file", DefaultGoogleTTSPathToServiceAccountKeyFile) viper.SetDefault("text-to-speech.google-text-to-speech.gender", DefaultGoogleTTSGender) viper.SetDefault("text-to-speech.google-text-to-speech.language-code", DefaultGoogleTTSLanguageCode) viper.SetDefault("text-to-speech.google-text-to-speech.speaking-rate", DefaultGoogleTTSSpeakingRate) diff --git a/internal/talker.go b/internal/talker.go index 6710fd5..010f1b5 100644 --- a/internal/talker.go +++ b/internal/talker.go @@ -50,9 +50,9 @@ func NewTalker(ctx context.Context, tc config.TalkConfig, logger *zap.Logger) (* Clarity: c.Clarity, Logger: logger, } - } else if c := tc.TextToSpeech.GoogleTextTOSpeech; c.PathToKeyfile != "" { + } else if c := tc.TextToSpeech.GoogleTextTOSpeech; c.PathToServiceAccountKeyFile != "" { // todo if proxy is not supported, use http client instead - client, err := texttospeech.NewClient(ctx, option.WithCredentialsFile(c.PathToKeyfile)) + client, err := texttospeech.NewClient(ctx, option.WithCredentialsFile(c.PathToServiceAccountKeyFile)) if err != nil { return nil, errors.Wrap(err, "failed to initialise Google text-to-speech client") }