Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
chore: Refactor Google Text-to-Speech configuration and key file paths
Browse files Browse the repository at this point in the history
- Renamed `PathToKeyfile` to `PathToServiceAccountKeyFile` in `GoogleTextTOSpeechConfig`
- Renamed "google_credentials.json" to "google-service-account-key.json" in `.gitignore`
- Updated path to Google service account key file in `talk.sample.yaml`
- Updated language code, gender preference, speaking rate, pitch, and volume gain for Google Text-to-Speech in `talk.sample.yaml`
- Renamed `DefaultGoogleTTSPathToKeyfile` to `DefaultGoogleTTSPathToServiceAccountKeyFile` in `parse.go`
- Modified if statement and error message in `talker.go` for Google text-to-speech client initialization.
  • Loading branch information
clement2026 committed Aug 13, 2023
1 parent 2e073c1 commit 30e8624
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configs/talk.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 13 additions & 13 deletions internal/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/talker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 30e8624

Please sign in to comment.