akupriyanovhse

Функция конвертации аудио

Mar 2nd, 2026
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import subprocess
  2. from pathlib import Path
  3.  
  4.  
  5. def to_wav(input_file, output_file=None):
  6.     input_file = Path(input_file)
  7.     output_file = Path(output_file) if output_file else input_file.with_suffix(".wav")
  8.  
  9.     subprocess.run([
  10.         "ffmpeg",
  11.         "-i", str(input_file),
  12.         "-ac", "1",          # mono
  13.         "-ar", "16000",      # 16 kHz
  14.         "-acodec", "pcm_s16le",
  15.         str(output_file)
  16.     ], check=True)
  17.  
  18.     return output_file
Advertisement
Add Comment
Please, Sign In to add comment