mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 05:14:59 +00:00
style: Format code to comply with linter rules
This commit is contained in:
parent
5cde755976
commit
9c4a0043dd
1 changed files with 38 additions and 23 deletions
|
@ -78,14 +78,17 @@ def compress_audio(input_file, output_file, bitrate=MP3_BITRATE):
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
"-i", input_file,
|
"-i",
|
||||||
"-b:a", bitrate,
|
input_file,
|
||||||
"-ac", "1", # Mono audio
|
"-b:a",
|
||||||
|
bitrate,
|
||||||
|
"-ac",
|
||||||
|
"1", # Mono audio
|
||||||
"-y", # Overwrite output file
|
"-y", # Overwrite output file
|
||||||
output_file
|
output_file,
|
||||||
],
|
],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE
|
stderr=subprocess.PIPE,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
except subprocess.SubprocessError as e:
|
except subprocess.SubprocessError as e:
|
||||||
|
@ -126,7 +129,10 @@ def generate_audio_openai(text, output_file, voice=VOICE, bitrate=MP3_BITRATE):
|
||||||
else:
|
else:
|
||||||
compressed_size = os.path.getsize(output_file)
|
compressed_size = os.path.getsize(output_file)
|
||||||
reduction = (1 - compressed_size / original_size) * 100
|
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
|
# Clean up the temporary file
|
||||||
try:
|
try:
|
||||||
|
@ -186,10 +192,14 @@ def main():
|
||||||
"--force", action="store_true", help="Force regeneration of all audio files"
|
"--force", action="store_true", help="Force regeneration of all audio files"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
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(
|
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()
|
args = parser.parse_args()
|
||||||
|
@ -234,7 +244,10 @@ def main():
|
||||||
|
|
||||||
# Replace original with compressed version
|
# Replace original with compressed version
|
||||||
os.replace(temp_file, file_path)
|
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:
|
else:
|
||||||
print(f" ✗ Failed to compress")
|
print(f" ✗ Failed to compress")
|
||||||
if os.path.exists(temp_file):
|
if os.path.exists(temp_file):
|
||||||
|
@ -302,7 +315,9 @@ def main():
|
||||||
print(f" Would generate: {output_file}")
|
print(f" Would generate: {output_file}")
|
||||||
else:
|
else:
|
||||||
print(f" Generating: {output_file}")
|
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:
|
if success:
|
||||||
print(f" ✓ Generated audio file")
|
print(f" ✓ Generated audio file")
|
||||||
# Update metadata with the new message
|
# Update metadata with the new message
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue