mgbam commited on
Commit
af2fe4e
·
verified ·
1 Parent(s): f0d7cfb

Update agents/voiceover_agent.py

Browse files
Files changed (1) hide show
  1. agents/voiceover_agent.py +11 -10
agents/voiceover_agent.py CHANGED
@@ -1,16 +1,17 @@
1
- import requests
2
-
3
  class VoiceoverAgent:
4
- def __init__(self, api_key=None):
5
- self.api_key = api_key
6
 
7
  def generate_voiceover(self, text):
8
  if not self.api_key:
9
  return None
10
 
11
- response = requests.post(
12
- "https://api.elevenlabs.io/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM",
13
- headers={"xi-api-key": self.api_key},
14
- json={"text": text, "voice_settings": {"stability": 0.7, "similarity_boost": 0.8}}
15
- )
16
- return response.content
 
 
 
 
 
 
1
  class VoiceoverAgent:
2
+ def __init__(self):
3
+ self.api_key = os.getenv("ELEVENLABS_API_KEY")
4
 
5
  def generate_voiceover(self, text):
6
  if not self.api_key:
7
  return None
8
 
9
+ try:
10
+ response = requests.post(
11
+ "https://api.elevenlabs.io/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM",
12
+ headers={"xi-api-key": self.api_key},
13
+ json={"text": text, "voice_settings": {"stability": 0.7, "similarity_boost": 0.8}}
14
+ )
15
+ return response.content
16
+ except:
17
+ return None