TTS: configurable auth, Health check, Phoenix options; .env.example; Gitea CI workflow
Some checks failed
CI / build (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,9 +55,9 @@ func main() {
|
||||
// Initialize services
|
||||
sessionManager := session.NewManager(db, redisClient)
|
||||
|
||||
// Initialize ASR/TTS (using mocks for now)
|
||||
// Initialize ASR/TTS
|
||||
asrService := asr.NewMockASRService()
|
||||
ttsService := tts.NewMockTTSService()
|
||||
ttsService := newTTSService()
|
||||
|
||||
// Initialize LLM (using mock for now)
|
||||
llmGateway := llm.NewMockLLMGateway()
|
||||
@@ -128,6 +128,28 @@ func main() {
|
||||
log.Println("Server exited")
|
||||
}
|
||||
|
||||
// newTTSService returns a TTS service from env: use real API when TTS_API_KEY (or
|
||||
// ELEVENLABS_API_KEY) and TTS_VOICE_ID are set. Optional: TTS_BASE_URL (Phoenix),
|
||||
// TTS_AUTH_HEADER_NAME / TTS_AUTH_HEADER_VALUE (e.g. Authorization: Bearer),
|
||||
// USE_PHOENIX_TTS=true to require TTS_BASE_URL.
|
||||
func newTTSService() tts.Service {
|
||||
apiKey := getEnv("TTS_API_KEY", os.Getenv("ELEVENLABS_API_KEY"))
|
||||
voiceID := getEnv("TTS_VOICE_ID", os.Getenv("ELEVENLABS_VOICE_ID"))
|
||||
baseURL := getEnv("TTS_BASE_URL", "")
|
||||
authName := getEnv("TTS_AUTH_HEADER_NAME", "")
|
||||
authValue := getEnv("TTS_AUTH_HEADER_VALUE", "")
|
||||
usePhoenix := getEnv("USE_PHOENIX_TTS", "") == "true" || getEnv("USE_PHOENIX_TTS", "") == "1"
|
||||
if usePhoenix && baseURL == "" {
|
||||
baseURL = getEnv("PHOENIX_TTS_BASE_URL", "https://phoenix.example.com/tts/v1")
|
||||
}
|
||||
hasAuth := apiKey != "" || authValue != ""
|
||||
if hasAuth && voiceID != "" {
|
||||
opts := tts.TTSOptions{BaseURL: baseURL, AuthHeaderName: authName, AuthHeaderValue: authValue}
|
||||
return tts.NewElevenLabsTTSServiceWithOptionsFull(apiKey, voiceID, opts)
|
||||
}
|
||||
return tts.NewMockTTSService()
|
||||
}
|
||||
|
||||
func getEnv(key, defaultValue string) string {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user