Spaces:
Build error
Build error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
from pydub import AudioSegment
|
| 4 |
-
from docx import Document
|
| 5 |
-
import fitz # PyMuPDF
|
| 6 |
-
import os
|
| 7 |
-
import tempfile
|
| 8 |
-
|
| 9 |
-
# Load Huggingface TTS pipeline
|
| 10 |
-
tts = pipeline("text-to-speech", model="tts_en_cmu_us_slt")
|
| 11 |
-
|
| 12 |
-
def extract_text_from_pdf(pdf_path):
|
| 13 |
-
"""Extract text from a PDF file."""
|
| 14 |
-
pdf_document = fitz.open(pdf_path)
|
| 15 |
-
text = ""
|
| 16 |
-
for page_num in range(len(pdf_document)):
|
| 17 |
-
page = pdf_document[page_num]
|
| 18 |
-
text += page.get_text()
|
| 19 |
-
return text
|
| 20 |
-
|
| 21 |
-
def extract_text_from_docx(docx_path):
|
| 22 |
-
"""Extract text from a Word (.docx) file."""
|
| 23 |
-
doc = Document(docx_path)
|
| 24 |
-
text = [paragraph.text for paragraph in doc.paragraphs]
|
| 25 |
-
return "\n".join(text)
|
| 26 |
-
|
| 27 |
-
def process_file(file):
|
| 28 |
-
"""Process uploaded file and convert text to audio."""
|
| 29 |
-
file_extension = file.name.split('.')[-1].lower()
|
| 30 |
-
text = ""
|
| 31 |
-
|
| 32 |
-
try:
|
| 33 |
-
# Save uploaded file temporarily
|
| 34 |
-
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
| 35 |
-
temp_file.write(file.read())
|
| 36 |
-
temp_path =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|