Skip to content

Commit 2474e03

Browse files
committed
Added an input warning if there's no environment file.
1 parent c6a363b commit 2474e03

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

modules/voiceCloning.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
from elevenlabs import clone, generate, set_api_key, save, Voices, Voice
22
from dotenv import dotenv_values
3+
from os import listdir, system
34

45
import requests
56

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']
713

814
def voiceOverNoClone(transcript:str, output_file:str):
915
""" Function for recording the translated audio track.
@@ -14,7 +20,7 @@ def voiceOverNoClone(transcript:str, output_file:str):
1420
1521
No return type
1622
"""
17-
set_api_key(config["API_KEY"])
23+
set_api_key(api_key)
1824

1925
print("Generating a Voice Over...")
2026

@@ -34,7 +40,7 @@ def voiceOver(transcript:str, output_file:str):
3440
3541
No return type
3642
"""
37-
set_api_key(config["API_KEY"])
43+
set_api_key(api_key)
3844

3945
print("Generating a Voice Over...")
4046

@@ -58,7 +64,7 @@ def delete_cloned_voice():
5864
"""
5965
HEADERS = {
6066
"Accept": "application/json",
61-
"xi-api-key": config["API_KEY"]
67+
"xi-api-key": api_key
6268
}
6369

6470
voices = Voices.from_api()

0 commit comments

Comments
 (0)