Create basic app skeleton around pyinotify
This commit is contained in:
parent
2b34789f2d
commit
7fc073ed19
|
@ -1,4 +1,3 @@
|
|||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
@ -9,13 +8,17 @@ __pycache__/
|
|||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
include
|
||||
include/
|
||||
lib/
|
||||
lib64
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
|
@ -128,6 +131,7 @@ venv/
|
|||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
pyvenv.cfg
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
|
@ -160,3 +164,6 @@ cython_debug/
|
|||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# Database
|
||||
data
|
||||
data/
|
19
README.md
19
README.md
|
@ -1,2 +1,21 @@
|
|||
# notescriber
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
python notescriber.py
|
||||
```
|
||||
|
||||
## Testing
|
||||
Set up virtual environment:
|
||||
```bash
|
||||
python -m venv .
|
||||
source bin/activate
|
||||
make bootstrap
|
||||
make test
|
||||
```
|
||||
|
||||
Run tests:
|
||||
```bash
|
||||
make test
|
||||
```
|
|
@ -0,0 +1,15 @@
|
|||
# Makefile
|
||||
|
||||
# Command to run the tests
|
||||
TEST_CMD = python -m unittest discover -s tests -p "*_test.py"
|
||||
|
||||
# Target to run the tests
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
@$(TEST_CMD)
|
||||
|
||||
bootstrap:
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
# Default target
|
||||
default: test
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from notescriber.transcriber import Transcriber
|
||||
from notescriber.picker import Picker
|
||||
|
||||
if __name__ == '__main__':
|
||||
transcriber = Transcriber()
|
||||
picker = Picker("/home/octopusx/Code/test", transcriber)
|
||||
picker.observe()
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
from notescriber import notetaker
|
||||
from notescriber import picker
|
||||
from notescriber import transcriber
|
|
@ -0,0 +1,34 @@
|
|||
import pyinotify
|
||||
|
||||
class EventHandler(pyinotify.ProcessEvent):
|
||||
def process_IN_CREATE(self, event):
|
||||
print(f'New file: {event.pathname}')
|
||||
return event.pathname
|
||||
|
||||
class Picker:
|
||||
|
||||
directory = None
|
||||
callbackObject = None
|
||||
|
||||
def __init__(self, directory, callbackObject):
|
||||
self.directory = directory
|
||||
self.callbackObject = callbackObject
|
||||
|
||||
def observe(self):
|
||||
wm = pyinotify.WatchManager()
|
||||
notifier = pyinotify.Notifier(wm, EventHandler())
|
||||
wm.add_watch(self.directory, pyinotify.IN_CREATE, self.callbackObject.execute)
|
||||
|
||||
print(f'Watching {self.directory} for changes...')
|
||||
notifier.loop()
|
||||
|
||||
# def observe_directory(directory):
|
||||
# wm = pyinotify.WatchManager()
|
||||
# notifier = pyinotify.Notifier(wm, EventHandler())
|
||||
# wm.add_watch(directory, pyinotify.IN_CREATE)
|
||||
|
||||
# print(f'Watching {directory} for changes...')
|
||||
# notifier.loop()
|
||||
|
||||
# Use the function
|
||||
# observe_directory('/home/octopusx/Code/test')
|
|
@ -0,0 +1,6 @@
|
|||
class Transcriber:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def execute(self, audio_file):
|
||||
print("Transcribing audio file: " + audio_file.pathname)
|
|
@ -0,0 +1,22 @@
|
|||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "notescriber"
|
||||
version = "0.0.1"
|
||||
authors = [
|
||||
{ name="Tomasz Frątczak", email="accidentallycompetent@octopusx.de" },
|
||||
]
|
||||
description = "Watches a directory for new files, then triggers OpenAI whisper transcription service to convert voice notes into text notes in NextCloud."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://teapot.octopusx.de/accidentallycompetent/notescriber"
|
||||
Issues = "https://teapot.octopusx.de/accidentallycompetent/notescriber/issues"
|
|
@ -0,0 +1,2 @@
|
|||
whisper==1.1.10
|
||||
pyinotify==0.9.6
|
Loading…
Reference in New Issue