-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
46 lines (36 loc) · 1.31 KB
/
Copy pathstart.py
File metadata and controls
46 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# start.py
import os
import subprocess
import sys
def check_cuda():
"""Checks if CUDA is available by querying nvidia-smi."""
try:
subprocess.run(["nvidia-smi"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
return True, "GPU Detected"
except (FileNotFoundError, subprocess.CalledProcessError):
return False, "No GPU detected (nvidia-smi failed or missing)"
def main():
print("🔍 HeadlineBot Smart Runner: Detecting Environment...")
is_gpu, gpu_reason = check_cuda()
if is_gpu:
mode = 'WHISPER'
print(f"🚀 {gpu_reason}. Transcription Mode: WHISPER")
else:
mode = 'GEMINI'
print(f"⚠️ {gpu_reason}. Transcription Mode: GEMINI (CPU)")
# Set Environment Variable
os.environ['TRANSCRIPTION_MODE'] = mode
# Launch main.py
print(f"🚀 Starting HeadlineBot in {mode} Mode...")
try:
# Use sys.executable to ensure we use the same environment
cmd = [sys.executable, "main.py"]
# In Colab/Terminal, we want to see the output in real-time
process = subprocess.Popen(cmd)
process.wait()
except KeyboardInterrupt:
print("\n🛑 Runner stopped by user.")
except Exception as e:
print(f"❌ Runner Error: {e}")
if __name__ == "__main__":
main()