Spaces:
Sleeping
Sleeping
File size: 596 Bytes
c71e312 d12a206 c71e312 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import ffmpeg
import uuid
import os
class AudioConverterService:
def convert_to_pcm(self, input_path: str) -> str:
output_path = os.path.join("/tmp", f"temp_{uuid.uuid4().hex}.wav")
try:
(
ffmpeg
.input(input_path)
.output(output_path, ac=1, ar=16000, sample_fmt='s16')
.overwrite_output()
.run(quiet=True)
)
return output_path
except ffmpeg.Error as e:
raise RuntimeError("Error al convertir el archivo a formato PCM 16-bit mono") from e
|