Spaces:
Sleeping
Sleeping
| import os | |
| import requests | |
| import io | |
| import pdfplumber | |
| def extract_resume_text(file_url: str) -> str: | |
| HF_TOKEN = os.getenv("HF_TOKEN") | |
| headers = {"Authorization": f"Bearer {HF_TOKEN}"} | |
| try: | |
| response = requests.get(file_url, headers=headers, timeout=30) | |
| response.raise_for_status() | |
| pdf_bytes = io.BytesIO(response.content) | |
| text = "" | |
| with pdfplumber.open(pdf_bytes) as pdf: | |
| for page in pdf.pages: | |
| page_text = page.extract_text() | |
| if page_text: | |
| text += page_text + "\n" | |
| return text.strip() | |
| except Exception as e: | |
| raise RuntimeError(f"Failed to extract text from resume: {str(e)}") |