ciyidogan commited on
Commit
ec49027
Β·
verified Β·
1 Parent(s): 975aa9d

Update stt/stt_google.py

Browse files
Files changed (1) hide show
  1. stt/stt_google.py +21 -10
stt/stt_google.py CHANGED
@@ -27,7 +27,7 @@ from .stt_interface import STTInterface, STTConfig, TranscriptionResult
27
  class GoogleCloudSTT(STTInterface):
28
  """Google Cloud Speech-to-Text implementation"""
29
 
30
- def __init__(self):
31
  """Initialize Google Cloud STT"""
32
  log_info("🎀 Creating STT provider: google")
33
 
@@ -49,16 +49,27 @@ class GoogleCloudSTT(STTInterface):
49
  self.chunk_count = 0 # Audio chunk counter
50
  self.total_bytes = 0 # Total bytes received
51
 
52
- # Check Google credentials
53
- creds_path = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
54
- if not creds_path:
55
- # Try default location
56
- creds_path = "./credentials/google-service-account.json"
57
- if os.path.exists(creds_path):
58
- os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = creds_path
59
- log_info(f"βœ… Google credentials set from: {creds_path}")
60
  else:
61
- raise ValueError("Google credentials not found. Please set GOOGLE_APPLICATION_CREDENTIALS")
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  # Test credentials
64
  try:
 
27
  class GoogleCloudSTT(STTInterface):
28
  """Google Cloud Speech-to-Text implementation"""
29
 
30
+ def __init__(self, credentials_path: Optional[str] = None):
31
  """Initialize Google Cloud STT"""
32
  log_info("🎀 Creating STT provider: google")
33
 
 
49
  self.chunk_count = 0 # Audio chunk counter
50
  self.total_bytes = 0 # Total bytes received
51
 
52
+ # Set Google credentials
53
+ if credentials_path:
54
+ # ConfigProvider'dan gelen path'i kullan
55
+ if os.path.exists(credentials_path):
56
+ os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
57
+ log_info(f"βœ… Google credentials set from: {credentials_path}")
 
 
58
  else:
59
+ log_error(f"❌ Credentials file not found: {credentials_path}")
60
+ raise ValueError(f"Google credentials file not found: {credentials_path}")
61
+ else:
62
+ # Fallback to environment variable
63
+ creds_path = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
64
+ if not creds_path:
65
+ # Try default location
66
+ creds_path = "./credentials/google-service-account.json"
67
+ if os.path.exists(creds_path):
68
+ os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = creds_path
69
+ log_info(f"βœ… Google credentials set from default: {creds_path}")
70
+ else:
71
+ raise ValueError("Google credentials not found. Please provide credentials_path")
72
+
73
 
74
  # Test credentials
75
  try: