Merge branch 'main' of https://gitlab.com/brausjonas/datenbanken-llm
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,25 @@
|
|||||||
|
import pymupdf
|
||||||
|
import io
|
||||||
|
from PIL import Image
|
||||||
|
import pytesseract
|
||||||
|
|
||||||
|
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
|
||||||
|
|
||||||
|
def extrahiere_text_und_bilder(pdf_datei):
|
||||||
|
doc = pymupdf.open(pdf_datei)
|
||||||
|
text = ""
|
||||||
|
for seite in doc:
|
||||||
|
text += seite.get_text()
|
||||||
|
for bild in seite.get_images(full=True):
|
||||||
|
xref = bild[0]
|
||||||
|
basis_bild = doc.extract_image(xref)
|
||||||
|
bild_daten = basis_bild["image"]
|
||||||
|
bild_objekt = Image.open(io.BytesIO(bild_daten))
|
||||||
|
bild_text = pytesseract.image_to_string(bild_objekt, lang="deu")
|
||||||
|
text += " " + bild_text
|
||||||
|
return text
|
||||||
|
|
||||||
|
pdf_datei = 'any.pdf'
|
||||||
|
text = extrahiere_text_und_bilder(pdf_datei)
|
||||||
|
|
||||||
|
print(text)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import whisper
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
model = whisper.load_model('tiny')
|
||||||
|
|
||||||
|
|
||||||
|
result = model.transcribe(str("Aufzeichnung.mp3"), language='de', verbose=True)
|
||||||
|
|
||||||
|
# Dump the results to a JSON file
|
||||||
|
with open('transcript.json', "w") as file:
|
||||||
|
json.dump(result['text'], file, indent=4)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
" Hallo, das ist ein Test, Hello World."
|
||||||
Reference in New Issue
Block a user