-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht2s.py
More file actions
30 lines (25 loc) · 665 Bytes
/
t2s.py
File metadata and controls
30 lines (25 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
import os
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv('API_KEY_T2S')
CHUNK_SIZE = 1024
url = "https://api.elevenlabs.io/v1/text-to-speech/9BWtsMINqrJLrRacOk9x"
headers = {
"Accept": "audio/mpeg",
"Content-Type": "application/json",
"xi-api-key": api_key
}
data = {
"text": "hola i'm arif",
"model_id": "eleven_monolingual_v1",
"voice_settings": {
"stability": 0.75,
"similarity_boost": 0.8
}
}
response = requests.post(url, json=data, headers=headers)
with open('output.mp3', 'wb') as f:
for chunk in response.iter_content(chunk_size=CHUNK_SIZE):
if chunk:
f.write(chunk)