dfasdfsdfsd
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
import os, pymupdf, whisper, json
|
import os, pymupdf, whisper, json
|
||||||
|
|
||||||
|
import cv2
|
||||||
|
import pytesseract
|
||||||
|
|
||||||
|
|
||||||
def read_files(path, output, filetypes=None):
|
def read_files(path, output, filetypes=None):
|
||||||
if filetypes is None:
|
if filetypes is None:
|
||||||
filetypes = ["pdf", "txt", "png", "jpg", "mp3"]
|
filetypes = ["pdf", "txt", "png", "jpg", "mp3"]
|
||||||
@@ -27,5 +31,12 @@ def extract_mp3_content(mp3_datei):
|
|||||||
|
|
||||||
result = model.transcribe(str(mp3_datei), language='de', verbose=True)
|
result = model.transcribe(str(mp3_datei), language='de', verbose=True)
|
||||||
|
|
||||||
with open('transcript.json', "w") as f:
|
# with open('transcript.json', "w") as f:
|
||||||
json.dump(result['text'], f, indent=4)
|
# json.dump(result['text'], f, indent=4)
|
||||||
|
|
||||||
|
return result["text"]
|
||||||
|
|
||||||
|
def extract_image_content(path):
|
||||||
|
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
|
||||||
|
img = cv2.imread(path)
|
||||||
|
return pytesseract.image_to_string(img)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import json
|
|||||||
def retrieve_file_contents(path):
|
def retrieve_file_contents(path):
|
||||||
file_extraction_functions = {
|
file_extraction_functions = {
|
||||||
"pdf": lambda path: lib.extract_pdf_content(path),
|
"pdf": lambda path: lib.extract_pdf_content(path),
|
||||||
"jpg": lambda path: "",
|
"jpg": lambda path: lib.extract_image_content(path),
|
||||||
"png": lambda path: "",
|
"png": lambda path: lib.extract_image_content(path),
|
||||||
"txt": lambda path: lib.extract_pdf_content(path),
|
"txt": lambda path: lib.extract_pdf_content(path),
|
||||||
"mp3": lambda path: lib.extract_mp3_content(path),
|
"mp3": lambda path: lib.extract_mp3_content(path),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user