feat(voice_to_text_tray): add journal saving for transcription results
- Add functionality to save transcription results to a journal file. - Use current date and time to organize entries in the journal. - Retain clipboard copy behavior for non-journal modes. - Enhance error handling for journal writing operations. Signed-off-by: Max P. <Mail@MPassarello.de>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
@@ -95,12 +96,25 @@ class WhisperWorker(QThread):
|
|||||||
print("Kein Ollama Prompt angegeben, nur Whisper Ergebnis verwendet.")
|
print("Kein Ollama Prompt angegeben, nur Whisper Ergebnis verwendet.")
|
||||||
|
|
||||||
# Ergebnis ins Clipboard kopieren
|
# Ergebnis ins Clipboard kopieren
|
||||||
try:
|
if CURRENT_PRESET["mode"] == "journal":
|
||||||
subprocess.run(["wl-copy"], input=formatted_result.encode(), check=True)
|
today = datetime.date.today().strftime("%Y.%m.%d")
|
||||||
except subprocess.CalledProcessError as e:
|
journal_path = os.path.join(CONFIGURATION["journal_path"], f"{today} - {CURRENT_PRESET['journal_name']}.md")
|
||||||
print(f"Clipboard Fehler: {e}")
|
now = datetime.datetime.now().strftime("%H:%M")
|
||||||
notify("Fehler", "Ein Fehler beim Kopieren des Ergebnisses ist aufgetreten!")
|
try:
|
||||||
return
|
with open(journal_path, "a") as f:
|
||||||
|
f.write(f"## {now}\n")
|
||||||
|
f.write(f"{formatted_result}\n\n")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Journal Fehler: {e}")
|
||||||
|
notify("Fehler", "Ein Fehler beim Schreiben ins Journal ist aufgetreten!")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
subprocess.run(["wl-copy"], input=formatted_result.encode(), check=True)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Clipboard Fehler: {e}")
|
||||||
|
notify("Fehler", "Ein Fehler beim Kopieren des Ergebnisses ist aufgetreten!")
|
||||||
|
return
|
||||||
|
|
||||||
notify("Spracherkennung", "Transkription abgeschlossen!")
|
notify("Spracherkennung", "Transkription abgeschlossen!")
|
||||||
play_sound()
|
play_sound()
|
||||||
|
Reference in New Issue
Block a user