Add TTD watchdog

This commit is contained in:
ceb515 2024-02-15 13:55:23 -05:00
parent d52c40f557
commit 1371411f62
2 changed files with 24 additions and 0 deletions

View File

@ -93,6 +93,19 @@ async def upload_to_discord(mp4_file,text):
else:
print(f"Could not find channel with ID {channel}")
def launch_and_watch(program_path):
while True:
process = subprocess.Popen(program_path)
process.wait()
if process.returncode != 0:
print("TTD has crashed. Relaunching...")
else:
print("TTD has exited normally.")
break
# Wait for a few seconds before relaunching
time.sleep(5)
if __name__ == "__main__":
## initialize watchdogs
@ -101,11 +114,15 @@ if __name__ == "__main__":
observer.schedule(event_handler, secrets_file.watch_folder, recursive=False)
observer.start()
## Launch TTD
launch_and_watch(secrets_file.ttd_path)
## initialize discord
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
client.run(secrets_file.key)
try:
while True:

View File

@ -1,5 +1,12 @@
## TwoToneDetect Executable Path
ttd_path = "C:\\PATH\\TO\\TTD.exe"
## Discord Bot Token
key = 'Bot Token'
## Folder to Watch for output audio
watch_folder = '/path/to/folder'
## Discord Channel ID to send notifications
channel_id = channel_id_number
## Generally a good idea.
delete_after_upload=True
## This will slow down pages and is unreliable.
speech_to_text = True