Skip to content

Commit

Permalink
Modified Google Credentials using Env Variables in the vbridge...SSML…
Browse files Browse the repository at this point in the history
….py file

Added .env file to include the Google SDK Credentials
Modified requirements.txt file
Added .gitignore file with updates
  • Loading branch information
mayannath committed Sep 14, 2024
1 parent f3971e5 commit 7773270
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GOOGLE_APPLICATION_CREDENTIALS=/workspaces/VocalBridge/credentials/psychic-karma-434602-f2-fd6bcd4cd937.json
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Virtual environment
venv/
myenv/
.env/
.venv/

# Log files
*.log

# macOS specific files
.DS_Store

# Windows specific files
Thumbs.db

# Ignore IDE-specific folders
.vscode/
.idea/

# Other system files
*.swp

# Python package files
*.egg-info/
*.eggs/

# GitHub Codespaces or Docker development container
.devcontainer/

# Ignore Google Cloud credentials or API keys (make sure these are excluded)
*.json
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pydub==0.25.1
Pygments==2.18.0
pyparsing==3.1.4
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-multipart==0.0.9
pytz==2024.2
PyYAML==6.0.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from dotenv import load_dotenv
import uuid
import gradio as gr
from google.cloud import translate_v2 as translate
Expand All @@ -8,10 +9,15 @@
from pathlib import Path
import openai

# Load environment variables from .env file
load_dotenv()

# Get the credentials path from environment variable
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")

# Initialize Google Translate client
def init_google_translate_client():
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/Users/mayan/VoiceBridgeApp/myenv/psychic-karma-434602-f2-fd6bcd4cd937.json" # Set your credentials path
return translate.Client()
return translate.Client() # Google Cloud SDK will automatically use the credentials from the environment with this approach

translate_client = init_google_translate_client()

Expand Down

0 comments on commit 7773270

Please sign in to comment.