import wave
def pcm_to_wav(pcm_path, wav_path, rate=16000, channels=1, bit_depth=16):
with open(pcm_path, 'rb') as pcm_file:
pcm_data = pcm_file.read()
with wave.open(wav_path, 'wb') as wav_file:
wav_file.setnchannels(channels)
wav_file.setsampwidth(bit_depth // 8)
wav_file.setframerate(rate)
wav_file.writeframes(pcm_data)
# 示例调用
pcm_to_wav("input.pcm", "output.wav", rate=16000, channels=1, bit_depth=16)
将pcm文件转成wav文件/python
最新推荐文章于 2025-04-11 12:05:25 发布