diff --git a/lib.py b/lib.py index f81a156..c90a7a5 100644 --- a/lib.py +++ b/lib.py @@ -1,4 +1,4 @@ -import os, pymupdf +import os, pymupdf, whisper, json def read_files(path, output, filetypes=None): if filetypes is None: @@ -19,4 +19,13 @@ def extract_pdf_content(pdf_datei): a = "" for page in doc: a += page.get_text() - return a \ No newline at end of file + 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) \ No newline at end of file diff --git a/main.py b/main.py index 26e9928..0866891 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ def retrieve_file_contents(path): "jpg": lambda path: "", "png": lambda 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 := [])