Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- from pathlib import Path
- def to_wav(input_file, output_file=None):
- input_file = Path(input_file)
- output_file = Path(output_file) if output_file else input_file.with_suffix(".wav")
- subprocess.run([
- "ffmpeg",
- "-i", str(input_file),
- "-ac", "1", # mono
- "-ar", "16000", # 16 kHz
- "-acodec", "pcm_s16le",
- str(output_file)
- ], check=True)
- return output_file
Advertisement
Add Comment
Please, Sign In to add comment