Update agents/voiceover_agent.py
Browse files- 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
|
| 5 |
-
self.api_key =
|
| 6 |
|
| 7 |
def generate_voiceover(self, text):
|
| 8 |
if not self.api_key:
|
| 9 |
return None
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|