1
1
from elevenlabs import clone , generate , set_api_key , save , Voices , Voice
2
2
from dotenv import dotenv_values
3
+ from os import listdir , system
3
4
4
5
import requests
5
6
6
- config = dotenv_values (".env" )
7
+ if not '.env' in listdir ('.' ):
8
+ api_key = input ("Please input your api key: " )
9
+ system (f'echo "API_KEY={ str (api_key )} " > .env' )
10
+ else :
11
+ config = dotenv_values (".env" )
12
+ api_key = config ['API_KEY' ]
7
13
8
14
def voiceOverNoClone (transcript :str , output_file :str ):
9
15
""" Function for recording the translated audio track.
@@ -14,7 +20,7 @@ def voiceOverNoClone(transcript:str, output_file:str):
14
20
15
21
No return type
16
22
"""
17
- set_api_key (config [ "API_KEY" ] )
23
+ set_api_key (api_key )
18
24
19
25
print ("Generating a Voice Over..." )
20
26
@@ -34,7 +40,7 @@ def voiceOver(transcript:str, output_file:str):
34
40
35
41
No return type
36
42
"""
37
- set_api_key (config [ "API_KEY" ] )
43
+ set_api_key (api_key )
38
44
39
45
print ("Generating a Voice Over..." )
40
46
@@ -58,7 +64,7 @@ def delete_cloned_voice():
58
64
"""
59
65
HEADERS = {
60
66
"Accept" : "application/json" ,
61
- "xi-api-key" : config [ "API_KEY" ]
67
+ "xi-api-key" : api_key
62
68
}
63
69
64
70
voices = Voices .from_api ()
0 commit comments