style: Format code to comply with linter rules

This commit is contained in:
Paul Gauthier (aider) 2025-03-14 18:55:36 -07:00
parent 5cde755976
commit 9c4a0043dd

View file

@ -78,14 +78,17 @@ def compress_audio(input_file, output_file, bitrate=MP3_BITRATE):
subprocess.run(
[
"ffmpeg",
"-i", input_file,
"-b:a", bitrate,
"-ac", "1", # Mono audio
"-i",
input_file,
"-b:a",
bitrate,
"-ac",
"1", # Mono audio
"-y", # Overwrite output file
output_file
output_file,
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
stderr=subprocess.PIPE,
)
return True
except subprocess.SubprocessError as e:
@ -126,7 +129,10 @@ def generate_audio_openai(text, output_file, voice=VOICE, bitrate=MP3_BITRATE):
else:
compressed_size = os.path.getsize(output_file)
reduction = (1 - compressed_size / original_size) * 100
print(f" Compressed: {original_size}{compressed_size} bytes ({reduction:.1f}% reduction)")
print(
f" Compressed: {original_size}{compressed_size} bytes ({reduction:.1f}%"
" reduction)"
)
# Clean up the temporary file
try:
@ -186,10 +192,14 @@ def main():
"--force", action="store_true", help="Force regeneration of all audio files"
)
parser.add_argument(
"--bitrate", default=MP3_BITRATE, help=f"MP3 bitrate for compression (default: {MP3_BITRATE})"
"--bitrate",
default=MP3_BITRATE,
help=f"MP3 bitrate for compression (default: {MP3_BITRATE})",
)
parser.add_argument(
"--compress-only", action="store_true", help="Only compress existing files without generating new ones"
"--compress-only",
action="store_true",
help="Only compress existing files without generating new ones",
)
args = parser.parse_args()
@ -234,7 +244,10 @@ def main():
# Replace original with compressed version
os.replace(temp_file, file_path)
print(f" ✓ Compressed: {original_size}{compressed_size} bytes ({reduction:.1f}% reduction)")
print(
f" ✓ Compressed: {original_size}{compressed_size} bytes"
f" ({reduction:.1f}% reduction)"
)
else:
print(f" ✗ Failed to compress")
if os.path.exists(temp_file):
@ -302,7 +315,9 @@ def main():
print(f" Would generate: {output_file}")
else:
print(f" Generating: {output_file}")
success = generate_audio_openai(message, output_file, voice=selected_voice, bitrate=selected_bitrate)
success = generate_audio_openai(
message, output_file, voice=selected_voice, bitrate=selected_bitrate
)
if success:
print(f" ✓ Generated audio file")
# Update metadata with the new message