Skip to content

Commit afaa93e

Browse files
committed
2 parents 83c7201 + 4f13fac commit afaa93e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

main.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,21 @@ def get_client(engine: str):
8484
aws_access_key = os.getenv('POLLY_AWS_ACCESS_KEY')
8585
return PollyClient(credentials=(region, aws_key_id, aws_access_key))
8686
elif engine == 'google':
87-
google_creds_path = os.getenv("GOOGLE_CREDS_PATH")
88-
if not google_creds_path:
87+
creds_path = os.getenv('GOOGLE_CREDS_PATH')
88+
google_creds_json = os.getenv("GOOGLE_CREDS_JSON")
89+
90+
if not google_creds_json:
91+
raise ValueError("GOOGLE_CREDS_JSON environment variable is not set")
92+
93+
if not creds_path:
8994
raise ValueError("GOOGLE_CREDS_PATH environment variable is not set")
90-
else:
91-
if not os.path.exists(google_creds_path):
92-
raise ValueError(f"Google credentials file not found at {google_creds_path}")
93-
94-
logger.info(f"Google credentials path: {google_creds_path}")
95-
return GoogleClient(credentials=(google_creds_path))
95+
96+
with open(creds_path, "w") as f:
97+
f.write(google_creds_json)
98+
f.close()
99+
100+
logger.info(f"Google credentials path: {creds_path}")
101+
return GoogleClient(credentials=(creds_path))
96102
elif engine == 'microsoft':
97103
token = os.getenv('MICROSOFT_TOKEN')
98104
region = os.getenv('MICROSOFT_REGION')

0 commit comments

Comments
 (0)