Spaces:
Sleeping
Sleeping
File size: 889 Bytes
ea6c2a8 f7da8c2 ea6c2a8 fc903d0 ea6c2a8 e0c636b ea6c2a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import logging
import subprocess
import numpy as np
def speed_change(input_audio: np.ndarray, speed_factor: float, sr: int):
"""这里修改为使用原数据float32变速,GPT-SoVITS官方为int16"""
raw_audio = input_audio.tobytes()
ffmpeg_command = [
# f'{BASE_DIR}/bin/ffmpeg',
'ffmpeg',
'-f', 'f32le',
'-ar', str(sr),
'-ac', '1',
'-i', 'pipe:',
'-filter:a', f'atempo={speed_factor}',
'-f', 'f32le',
'-acodec', 'pcm_f32le',
'pipe:'
]
ffmpeg_process = subprocess.Popen(
ffmpeg_command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
out, info = ffmpeg_process.communicate(input=raw_audio)
# 将管道输出解码为 NumPy 数组
processed_audio = np.frombuffer(out, np.float32)
return processed_audio
|