norhan12 commited on
Commit
64e2526
·
verified ·
1 Parent(s): bb23ef6

Update process_interview.py

Browse files
Files changed (1) hide show
  1. process_interview.py +16 -0
process_interview.py CHANGED
@@ -49,6 +49,22 @@ GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
49
 
50
  # --- All your original helper functions ---
51
  # I am including them exactly as you last provided them.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  def initialize_services():
54
  try:
 
49
 
50
  # --- All your original helper functions ---
51
  # I am including them exactly as you last provided them.
52
+ # --- HELPER FUNCTION to download from URL ---
53
+ def download_audio_from_url(url: str) -> str:
54
+ try:
55
+ temp_dir = tempfile.gettempdir()
56
+ temp_filename = f"{uuid.uuid4()}.tmp_audio"
57
+ local_filename = os.path.join(temp_dir, temp_filename)
58
+ logger.info(f"Downloading audio from {url} to {local_filename}")
59
+ with requests.get(url, stream=True) as r:
60
+ r.raise_for_status()
61
+ with open(local_filename, 'wb') as f:
62
+ for chunk in r.iter_content(chunk_size=8192):
63
+ f.write(chunk)
64
+ return local_filename
65
+ except Exception as e:
66
+ logger.error(f"Failed to download audio from URL {url}: {e}")
67
+ raise
68
 
69
  def initialize_services():
70
  try: