commited reqs

This commit is contained in:
Ahmad Alghooneh
2025-01-13 00:53:28 -05:00
parent a4eb4ea66d
commit 96ab01b0c1
2 changed files with 9 additions and 9 deletions

View File

@@ -3,12 +3,12 @@ import websockets
import json
import base64
from io import BytesIO
from application.tts.base import BaseTTS
from base import BaseTTS
class ElevenlabsTTS(BaseTTS):
def __init__(self):
self.api_key = "ELEVENLABS_API_KEY"
self.api_key = 'sk_19b72c883e8bdfcec2705be2d048f3830a40d2faa4b76b26'
self.model = "eleven_multilingual_v2"
self.voice = "Brian"
@@ -19,21 +19,20 @@ class ElevenlabsTTS(BaseTTS):
return audio_base64, lang
async def _text_to_speech_websocket(self, text):
uri = "wss://api.elevenlabs.io/v1/tts-stream"
headers = {
"xi-api-key": self.api_key,
"Accept": "audio/mpeg"
}
uri = f"wss://api.elevenlabs.io/v1/text-to-speech/{self.voice}/stream-input?model_id={self.model}"
payload = {
"text": text,
"model_id": self.model,
"voice_settings": {
"voice_id": self.voice
},
"xi-api-key": self.api_key,
"Accept": "audio/mpeg"
}
audio_data = BytesIO()
async with websockets.connect(uri, extra_headers=headers) as websocket:
async with websockets.connect(uri) as websocket:
await websocket.send(json.dumps(payload))