fix: Update gemini_transcribe.py to use active API Studio key and HTTP proxy
This commit is contained in:
parent
3a050af68a
commit
0262f2f982
1 changed files with 12 additions and 19 deletions
|
|
@ -2,26 +2,16 @@
|
|||
import os
|
||||
import sys
|
||||
import time
|
||||
from google.oauth2 import service_account
|
||||
import google.generativeai as genai
|
||||
|
||||
# Setup proxies for Google API routing through SOCKS5 proxy (RKN bypass)
|
||||
os.environ["https_proxy"] = "socks5h://127.0.0.1:10808"
|
||||
os.environ["http_proxy"] = "socks5h://127.0.0.1:10808"
|
||||
os.environ["all_proxy"] = "socks5h://127.0.0.1:10808"
|
||||
# Setup proxies for Google API routing through HTTP proxy (port 10809 is supported by gRPC)
|
||||
os.environ["https_proxy"] = "http://127.0.0.1:10809"
|
||||
os.environ["http_proxy"] = "http://127.0.0.1:10809"
|
||||
os.environ["all_proxy"] = "http://127.0.0.1:10809"
|
||||
|
||||
# Auth using Service Account (avoids invalid GCP API key errors)
|
||||
SERVICE_ACCOUNT_FILE = "/home/matrixhasyou/domovoy_google_creds.json"
|
||||
try:
|
||||
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)
|
||||
# Configure Gemini with the active AI Studio key
|
||||
API_KEY = "AIzaSyAJMfQ_mRZ1picRXVFNaeFJ7fpAkZxUKyk"
|
||||
genai.configure(api_key=API_KEY)
|
||||
|
||||
BOT_TOKEN = "8725618164:AAH1tGalq-pw1l0t4P5c0sdLkCVJdh7IE7M"
|
||||
CHAT_ID = "197957361"
|
||||
|
|
@ -104,8 +94,11 @@ def transcribe_audio(audio_path, output_prefix, model_name="gemini-1.5-pro"):
|
|||
finally:
|
||||
# Delete remote file from Google storage
|
||||
print("Cleaning up file from Google storage...", flush=True)
|
||||
genai.delete_file(name=audio_file.name)
|
||||
print("Cleanup done.", flush=True)
|
||||
try:
|
||||
genai.delete_file(name=audio_file.name)
|
||||
print("Cleanup done.", flush=True)
|
||||
except Exception as e:
|
||||
print(f"Cleanup error: {e}", flush=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
|
|
|
|||
Loading…
Reference in a new issue