python - 从歌曲中提取人声

标签 python algorithm audio signal-processing voice

我的问题是关于如何使用 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")

我需要提取歌曲中的人声

如果不是这个那么如何从一个音频文件中减去另一个音频文件

最佳答案

您始终可以使用 librosa 库,这是 python 中音频处理最喜欢的库。 它有助于将人声(和其他零星的前景信号)与伴奏乐器分开。

https://librosa.github.io/librosa_gallery/auto_examples/plot_vocal_separation.html

它获取切片并绘制相同的切片,但分为前景和背景

要保存提取的前景,您可以使用:

import librosa.output
import soundfile as sf
new_y = librosa.istft(S_foreground*phase)
sf.write("new-audio.wav", new_y, samplerate=sr, subtype='PCM_24')

关于python - 从歌曲中提取人声,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49279425/

相关文章:

algorithm - 非网格 map 中的沼泽/死胡同修剪

Python:超声波到音频范围

python - 如何设置带有 URL 的 tkinter 应用程序图标?

python - 使用 Python 的 Glitch.com

algorithm - 如何在 O(1) 复杂度(运行时)中反转字符串?

algorithm - 基本 Reed-Solomon 纠错问题

python - 如何避免为 python 文件中的每个更改重新启动 apache 服务器?

python - 如何在pygame中创建三点弧

javascript - 如何使用音频 API 分层相同的声音文件?

java - 我在 android 上使用 java 时遇到异常 (java.lang.NoClassDefFoundError),为什么?