diff --git a/.env.template b/.env.template index 01735615c..b4cde9389 100644 --- a/.env.template +++ b/.env.template @@ -2,6 +2,8 @@ PINECONE_API_KEY=your-pinecone-api-key PINECONE_ENV=your-pinecone-region OPENAI_API_KEY=your-openai-api-key ELEVENLABS_API_KEY=your-elevenlabs-api-key +ELEVENLABS_VOICE_1_ID=your-voice-id +ELEVENLABS_VOICE_2_ID=your-voice-id SMART_LLM_MODEL=gpt-4 FAST_LLM_MODEL=gpt-3.5-turbo GOOGLE_API_KEY= @@ -12,4 +14,4 @@ OPENAI_AZURE_API_VERSION=api-version-for-azure OPENAI_AZURE_DEPLOYMENT_ID=deployment-id-for-azure IMAGE_PROVIDER=dalle HUGGINGFACE_API_TOKEN= -USE_MAC_OS_TTS=False +USE_MAC_OS_TTS=False \ No newline at end of file diff --git a/scripts/config.py b/scripts/config.py index 24911bce9..1dd9c8808 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -54,6 +54,8 @@ class Config(metaclass=Singleton): openai.api_version = self.openai_api_version self.elevenlabs_api_key = os.getenv("ELEVENLABS_API_KEY") + self.elevenlabs_voice_1_id = os.getenv("ELEVENLABS_VOICE_1_ID") + self.elevenlabs_voice_2_id = os.getenv("ELEVENLABS_VOICE_2_ID") self.use_mac_os_tts = False self.use_mac_os_tts = os.getenv("USE_MAC_OS_TTS") @@ -113,6 +115,14 @@ class Config(metaclass=Singleton): """Set the ElevenLabs API key value.""" self.elevenlabs_api_key = value + def set_elevenlabs_voice_1_id(self, value: str): + """Set the ElevenLabs Voice 1 ID value.""" + self.elevenlabs_voice_1_id = value + + def set_elevenlabs_voice_2_id(self, value: str): + """Set the ElevenLabs Voice 2 ID value.""" + self.elevenlabs_voice_2_id = value + def set_google_api_key(self, value: str): """Set the Google API key value.""" self.google_api_key = value diff --git a/scripts/speak.py b/scripts/speak.py index 08b0c1c98..5eed28d43 100644 --- a/scripts/speak.py +++ b/scripts/speak.py @@ -7,9 +7,21 @@ import gtts import threading from threading import Lock, Semaphore +# Default voice IDs +default_voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"] -# TODO: Nicer names for these ids -voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"] +# Retrieve custom voice IDs from the Config class +custom_voice_1 = cfg.elevenlabs_voice_1_id +custom_voice_2 = cfg.elevenlabs_voice_2_id + +# Placeholder values that should be treated as empty +placeholders = {"your-voice-id"} + +# Use custom voice IDs if provided and not placeholders, otherwise use default voice IDs +voices = [ + custom_voice_1 if custom_voice_1 and custom_voice_1 not in placeholders else default_voices[0], + custom_voice_2 if custom_voice_2 and custom_voice_2 not in placeholders else default_voices[1] +] tts_headers = { "Content-Type": "application/json",