google env fixes

This commit is contained in:
Ajay Raj 2023-03-29 01:54:26 -07:00
commit 11af47482c
4 changed files with 13 additions and 21 deletions

View file

@ -1,4 +1,5 @@
import io
import os
import wave
from typing import Any, Optional
@ -23,10 +24,12 @@ class GoogleSynthesizer(BaseSynthesizer):
def __init__(self, synthesizer_config: GoogleSynthesizerConfig):
super().__init__(synthesizer_config)
# Instantiates a client
if not getenv("GOOGLE_APPLICATION_CREDENTIALS"):
credentials_path = getenv("GOOGLE_APPLICATION_CREDENTIALS")
if not credentials_path:
raise Exception(
"GOOGLE_APPLICATION_CREDENTIALS environment variable must be set"
"Please set GOOGLE_APPLICATION_CREDENTIALS environment variable"
)
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
self.client = tts.TextToSpeechClient()
# Build the voice request, select the language code ("en-US") and the ssml