Merge pull request #910 from dillweed/Elevenlabs-Voice-ID-ENV

Elevenlabs voice ID
pull/929/head
Toran Bruce Richards 2023-04-12 19:26:12 +12:00 committed by GitHub
commit 429317e6b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -2,6 +2,8 @@ PINECONE_API_KEY=your-pinecone-api-key
PINECONE_ENV=your-pinecone-region PINECONE_ENV=your-pinecone-region
OPENAI_API_KEY=your-openai-api-key OPENAI_API_KEY=your-openai-api-key
ELEVENLABS_API_KEY=your-elevenlabs-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 SMART_LLM_MODEL=gpt-4
FAST_LLM_MODEL=gpt-3.5-turbo FAST_LLM_MODEL=gpt-3.5-turbo
GOOGLE_API_KEY= GOOGLE_API_KEY=

View File

@ -54,6 +54,8 @@ class Config(metaclass=Singleton):
openai.api_version = self.openai_api_version openai.api_version = self.openai_api_version
self.elevenlabs_api_key = os.getenv("ELEVENLABS_API_KEY") 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 = False
self.use_mac_os_tts = os.getenv("USE_MAC_OS_TTS") 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.""" """Set the ElevenLabs API key value."""
self.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): def set_google_api_key(self, value: str):
"""Set the Google API key value.""" """Set the Google API key value."""
self.google_api_key = value self.google_api_key = value

View File

@ -7,9 +7,21 @@ import gtts
import threading import threading
from threading import Lock, Semaphore from threading import Lock, Semaphore
# Default voice IDs
default_voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"]
# TODO: Nicer names for these ids # Retrieve custom voice IDs from the Config class
voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"] 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 = { tts_headers = {
"Content-Type": "application/json", "Content-Type": "application/json",