puuush
puzshsahc usah
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import os, pymupdf
|
import os, pymupdf, whisper, json
|
||||||
|
|
||||||
def read_files(path, output, filetypes=None):
|
def read_files(path, output, filetypes=None):
|
||||||
if filetypes is None:
|
if filetypes is None:
|
||||||
@@ -19,4 +19,13 @@ def extract_pdf_content(pdf_datei):
|
|||||||
a = ""
|
a = ""
|
||||||
for page in doc:
|
for page in doc:
|
||||||
a += page.get_text()
|
a += page.get_text()
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
|
||||||
|
def extract_mp3_content(mp3_datei):
|
||||||
|
model = whisper.load_model('tiny')
|
||||||
|
|
||||||
|
result = model.transcribe(str(mp3_datei), language='de', verbose=True)
|
||||||
|
|
||||||
|
with open('transcript.json', "w") as f:
|
||||||
|
json.dump(result['text'], f, indent=4)
|
||||||
@@ -9,7 +9,7 @@ def retrieve_file_contents(path):
|
|||||||
"jpg": lambda path: "",
|
"jpg": lambda path: "",
|
||||||
"png": lambda path: "",
|
"png": lambda path: "",
|
||||||
"txt": lambda path: lib.extract_pdf_content(path),
|
"txt": lambda path: lib.extract_pdf_content(path),
|
||||||
"mp3": lambda path: "test mp3"
|
"mp3": lambda path: lib.extract_mp3_content(path),
|
||||||
}
|
}
|
||||||
|
|
||||||
lib.read_files(path, files := [])
|
lib.read_files(path, files := [])
|
||||||
|
|||||||
Reference in New Issue
Block a user