从歌曲中提取人声

2024-05-12 20:41:17 发布

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

我的问题是如何使用python语言提取音乐中的人声 我看过这段代码,但它提取了背景音乐

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: andthefromimportaudiofile人声inv