Create a working docker setup
This commit is contained in:
parent
53102be98b
commit
6eb24e74eb
|
@ -0,0 +1,10 @@
|
||||||
|
FROM python
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
COPY notescriber /app/notescriber
|
||||||
|
COPY notescriber.py /app/notescriber.py
|
||||||
|
COPY requirements.txt /app/requirements.txt
|
||||||
|
COPY .config.yaml /app/.config.yaml
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN pip install -r requirements.txt
|
|
@ -8,14 +8,11 @@ class Config:
|
||||||
url = None
|
url = None
|
||||||
path = None
|
path = None
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def parse_args(self):
|
def parse_args(self):
|
||||||
parser = argparse.ArgumentParser(description='Process some integers.')
|
parser = argparse.ArgumentParser(description='Process some integers.')
|
||||||
parser.add_argument('--path', type=str, help='Path to config yaml file')
|
parser.add_argument('--path', type=str, help='Path to config yaml file', dest='path')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args.arg
|
return args
|
||||||
|
|
||||||
def load_config(self, path=None):
|
def load_config(self, path=None):
|
||||||
if path is None:
|
if path is None:
|
||||||
|
@ -24,4 +21,7 @@ class Config:
|
||||||
self.username = confFile['username']
|
self.username = confFile['username']
|
||||||
self.password = confFile['password']
|
self.password = confFile['password']
|
||||||
self.url = confFile['url']
|
self.url = confFile['url']
|
||||||
|
self.path = self.parse_args().path
|
||||||
|
if self.path is None:
|
||||||
self.path = confFile['path']
|
self.path = confFile['path']
|
||||||
|
print(self.path)
|
|
@ -1,4 +1,5 @@
|
||||||
import threading
|
import threading
|
||||||
|
import os
|
||||||
|
|
||||||
class Dispatcher:
|
class Dispatcher:
|
||||||
|
|
||||||
|
@ -7,9 +8,6 @@ class Dispatcher:
|
||||||
extensionFilter = None
|
extensionFilter = None
|
||||||
noteGenerator = None
|
noteGenerator = None
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def add_audio_processor(self, audioProcessor):
|
def add_audio_processor(self, audioProcessor):
|
||||||
self.audioProcessor = audioProcessor
|
self.audioProcessor = audioProcessor
|
||||||
|
|
||||||
|
@ -19,11 +17,12 @@ class Dispatcher:
|
||||||
def process_audio_file(self, audio_file):
|
def process_audio_file(self, audio_file):
|
||||||
self.threads.append(threading.Thread(target=self._execute_thread, args=(audio_file,)))
|
self.threads.append(threading.Thread(target=self._execute_thread, args=(audio_file,)))
|
||||||
self.threads[-1].start()
|
self.threads[-1].start()
|
||||||
# TODO: we need to have a way to wipe old threads, otherwise we will have a memory leak
|
# TODO: we need to have a way to wipe old threads, otherwise we may have a memory leak
|
||||||
|
|
||||||
def _execute_thread(self, audio_file):
|
def _execute_thread(self, audio_file):
|
||||||
|
filename = os.path.basename(audio_file.pathname)
|
||||||
note = self.audioProcessor.execute(audio_file.pathname)
|
note = self.audioProcessor.execute(audio_file.pathname)
|
||||||
self.noteGenerator.generate_note(audio_file.pathname, note)
|
self.noteGenerator.generate_note(filename, note)
|
||||||
|
|
||||||
def halt(self):
|
def halt(self):
|
||||||
for thread in self.threads:
|
for thread in self.threads:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from nextcloud_notes_api import NotesApi, Note
|
from nextcloud_notes_api import NotesApi, Note
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
class Notetaker:
|
class Notetaker:
|
||||||
|
|
||||||
|
@ -11,7 +12,13 @@ class Notetaker:
|
||||||
self.password = password
|
self.password = password
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
|
def format_note(self, filename, note):
|
||||||
|
result = f"# {filename}\n\n"
|
||||||
|
result += f"-----------------\nTranscription date: {date.today()}\n-----------------\n\n"
|
||||||
|
result += note
|
||||||
|
return result
|
||||||
|
|
||||||
def generate_note(self, filename, note):
|
def generate_note(self, filename, note):
|
||||||
api = NotesApi(self.username, self.password, self.url)
|
api = NotesApi(self.username, self.password, self.url)
|
||||||
ncnote = Note(title=filename, content=note, category="Voicenotes")
|
ncnote = Note(title=filename, content=self.format_note(filename, note), category="Voicenotes")
|
||||||
api.create_note(ncnote)
|
api.create_note(ncnote)
|
||||||
|
|
|
@ -2,3 +2,4 @@ openai-whisper==20231117
|
||||||
pyinotify==0.9.6
|
pyinotify==0.9.6
|
||||||
nextcloud_notes_api==1.0.0
|
nextcloud_notes_api==1.0.0
|
||||||
PyYaml==6.0.1
|
PyYaml==6.0.1
|
||||||
|
pyasyncore==1.0.3
|
Loading…
Reference in New Issue