Skip to content

Move to flac #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: base-sha/a5336ef9e38cf2b71edeb9cc6b0012fb56d6087d
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions ttt.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def audio_notification(audiofile, apobj, body, title):
Examples:
audio_notification(audiofile, apobj, body, title)
"""
opusfile = Path(audiofile).with_suffix(".opus")
flacfile = Path(audiofile).with_suffix(".flac")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (edge_case_not_handled): Consider verifying the existence of the audio file before conversion.

Adding a check to ensure the audio file exists before attempting to convert it can prevent runtime errors if the file is missing.

Suggested change
flacfile = Path(audiofile).with_suffix(".flac")
from pathlib import Path
audiofile = "example_audio"
flacfile = Path(audiofile).with_suffix(".flac")
if flacfile.exists():
# Proceed with the existing code to handle the file
pass
else:
print(f"Error: The file {flacfile} does not exist.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment correct?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment helpful?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the comment type correct?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the comment area correct?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment become an LLM test?

ffmpeg_cmd = [
"ffmpeg",
"-y",
Expand All @@ -233,25 +233,19 @@ def audio_notification(audiofile, apobj, body, title):
"-filter:a",
"loudnorm=i=-14",
"-c:a",
"libopus",
"-application",
"voip",
"-cutoff",
"8000",
"-vbr",
"on",
opusfile,
"flac",
flacfile,
]
subprocess.run(ffmpeg_cmd, check=True, capture_output=True)

opusfile = str(opusfile)
flacfile = str(flacfile)
apobj.notify(
body=body,
title=title,
attach=opusfile,
attach=flacfile,
)
# Remove opusfile; audiofile and json unlinked later
Path.unlink(opusfile)
# Remove flacfile; audiofile and json unlinked later
Path.unlink(flacfile)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (edge_case_not_handled): Consider handling potential exceptions when unlinking the file.

Using a try-except block around the file deletion could prevent unhandled exceptions if the file does not exist or is locked, enhancing the robustness of the function.

Suggested change
Path.unlink(flacfile)
try:
Path.unlink(flacfile)
except FileNotFoundError:
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment correct?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment helpful?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the comment type correct?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the comment area correct?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment become an LLM test?



def import_notification_destinations():
Expand Down