通过去除背景音乐隔离人声

2024-09-27 07:31:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我想隔离人声和删除mp3文件中的背景音乐。我不需要完全摆脱背景音乐,但至少要把它最小化。在

我尝试了pydub,这有助于音频操作。我尝试了这个代码,删除人声和保留背景音乐。我需要做相反的事。我试着切换声音的单声道和反转另一个声道,但也没用。在

from pydub import AudioSegment
from pydub.playback import play

# read in audio file and get the two mono tracks
sound_stereo = AudioSegment.from_file(myAudioFile, format="mp3")
sound_monoL = sound_stereo.split_to_mono()[0]
sound_monoR = sound_stereo.split_to_mono()[1]

# Invert phase of the Right audio file
sound_monoR_inv = sound_monoR.invert_phase()

# Merge two L and R_inv files, this cancels out the centers
sound_CentersOut = sound_monoL.overlay(sound_monoR_inv)

# Export merged audio file
fh = sound_CentersOut.export(myAudioFile_CentersOut, format="mp3")

有人知道怎么解决这个问题吗?谢谢!在


Tags: thefromimportmp3audiofile人声inv
1条回答
网友
1楼 · 发布于 2024-09-27 07:31:07

如果您的sound_CentersOut已经删除了人声,为什么不使用sound_CentersOut的倒置形式对您的sound_stereo应用相位消除?在

# invert sound_CentersOut
sound_CentersOut_inv = sound_CentersOut.invert_phase()

# phase cancellation on original stereo with inverted sound_CentersOut
# the vocals should remain
vocals = sound_stereo.overlay(sound_CentersOut_inv)

请注意,大多数歌曲的中心都有人声和低音,因此您的人声中也可能包含低音。如果你真的想做手术,你可能需要做一些平衡来滤除低频。在

相关问题 更多 >

    热门问题