Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import speech_recognition as sr
|
| 3 |
import fitz # PyMuPDF
|
| 4 |
-
from transformers import
|
| 5 |
import torch
|
| 6 |
import faiss
|
| 7 |
import numpy as np
|
| 8 |
from gtts import gTTS
|
| 9 |
-
import os
|
| 10 |
|
| 11 |
# Function to convert audio file to text
|
| 12 |
def audio_to_text(audio_file):
|
|
@@ -51,8 +51,12 @@ model = AutoModel.from_pretrained("bert-base-uncased")
|
|
| 51 |
dimension = 768 # Size of BERT embeddings
|
| 52 |
index = faiss.IndexFlatL2(dimension)
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
texts = []
|
| 57 |
for path in pdf_paths:
|
| 58 |
pdf_text = extract_text_from_pdf(path)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
import speech_recognition as sr
|
| 4 |
import fitz # PyMuPDF
|
| 5 |
+
from transformers import AutoTokenizer, AutoModel
|
| 6 |
import torch
|
| 7 |
import faiss
|
| 8 |
import numpy as np
|
| 9 |
from gtts import gTTS
|
|
|
|
| 10 |
|
| 11 |
# Function to convert audio file to text
|
| 12 |
def audio_to_text(audio_file):
|
|
|
|
| 51 |
dimension = 768 # Size of BERT embeddings
|
| 52 |
index = faiss.IndexFlatL2(dimension)
|
| 53 |
|
| 54 |
+
# Folder path containing PDFs
|
| 55 |
+
pdf_folder_path = "path/to/your/pdf_folder"
|
| 56 |
+
|
| 57 |
+
# Read all PDF files from the specified folder
|
| 58 |
+
pdf_paths = [os.path.join(pdf_folder_path, f) for f in os.listdir(pdf_folder_path) if f.endswith('.pdf')]
|
| 59 |
+
|
| 60 |
texts = []
|
| 61 |
for path in pdf_paths:
|
| 62 |
pdf_text = extract_text_from_pdf(path)
|