fix: Update gemini_transcribe.py to use active API Studio key and HTTP proxy

This commit is contained in:
Admin 2026-07-05 22:12:17 +04:00
parent 3a050af68a
commit 0262f2f982

View file

@ -2,26 +2,16 @@
import os import os
import sys import sys
import time import time
from google.oauth2 import service_account
import google.generativeai as genai import google.generativeai as genai
# Setup proxies for Google API routing through SOCKS5 proxy (RKN bypass) # Setup proxies for Google API routing through HTTP proxy (port 10809 is supported by gRPC)
os.environ["https_proxy"] = "socks5h://127.0.0.1:10808" os.environ["https_proxy"] = "http://127.0.0.1:10809"
os.environ["http_proxy"] = "socks5h://127.0.0.1:10808" os.environ["http_proxy"] = "http://127.0.0.1:10809"
os.environ["all_proxy"] = "socks5h://127.0.0.1:10808" os.environ["all_proxy"] = "http://127.0.0.1:10809"
# Auth using Service Account (avoids invalid GCP API key errors) # Configure Gemini with the active AI Studio key
SERVICE_ACCOUNT_FILE = "/home/matrixhasyou/domovoy_google_creds.json" API_KEY = "AIzaSyAJMfQ_mRZ1picRXVFNaeFJ7fpAkZxUKyk"
try: genai.configure(api_key=API_KEY)
creds = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE,
scopes=["https://www.googleapis.com/auth/generative-language", "https://www.googleapis.com/auth/drive"]
)
genai.configure(credentials=creds)
print("Authenticated successfully using Google Service Account.", flush=True)
except Exception as e:
print(f"Authentication failed: {e}", flush=True)
sys.exit(1)
BOT_TOKEN = "8725618164:AAH1tGalq-pw1l0t4P5c0sdLkCVJdh7IE7M" BOT_TOKEN = "8725618164:AAH1tGalq-pw1l0t4P5c0sdLkCVJdh7IE7M"
CHAT_ID = "197957361" CHAT_ID = "197957361"
@ -104,8 +94,11 @@ def transcribe_audio(audio_path, output_prefix, model_name="gemini-1.5-pro"):
finally: finally:
# Delete remote file from Google storage # Delete remote file from Google storage
print("Cleaning up file from Google storage...", flush=True) print("Cleaning up file from Google storage...", flush=True)
try:
genai.delete_file(name=audio_file.name) genai.delete_file(name=audio_file.name)
print("Cleanup done.", flush=True) print("Cleanup done.", flush=True)
except Exception as e:
print(f"Cleanup error: {e}", flush=True)
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 3: if len(sys.argv) < 3: