已解決: vocal remover 源代碼 python

vocal remover 源代碼 python 的主要問題是它不是開源的。 這意味著該代碼不可用於任何人審查和潛在的改進。 這可能會導致軟件的可靠性和整體質量出現問題。

import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile
from scipy import signal
from scipy.fftpack import fft, ifft
import os


def vocal_remover(filename):

    # read in audio file 
    fs, data = wavfile.read(filename)

    # take the absolute value of the signal 
    data = np.absolute(data)

    # find the length of the signal 
    N = len(data)

    # take the Fourier Transform of the signal 
    fourier = fft(data)

    # create a list of frequencies corresponding to the length of the signal 
    freqs = np.fft.fftfreq(N, 1/fs)

     # find all frequencies above 1000 Hz (1 kHz) and set them to 0 in Fourier Transform 
     for i in range (len(fourier)):   if abs(freqs[i]) > 1000:   fourier[i] = 0+0j

     # take inverse Fourier Transform to get back to time domain 
     inverse_fourier = ifft(fourier).real

     return inverse_fourier

此代碼正在導入將在 vocal_remover 函數中使用的各種庫。

vocal_remover 函數接受文件名的輸入,並使用 wavfile 庫讀入音頻文件。

然後它取信號的絕對值,並找到信號的長度。

然後將信號通過傅立葉變換,創建與信號長度相對應的頻率列表。

在傅里葉變換中,所有高於 1000 Hz 的頻率都設置為 0。 這是因為大多數人聲都在這個頻率範圍內。

進行傅里葉逆變換是為了回到時域,這個最終信號由函數返回。

處理角色

在 Python 中有幾種處理字符的方法。 一種方法是使用 str() 函數來獲取字符的字符串表示形式。 例如,以下代碼在屏幕上打印字母“a”:

print(“字母‘a’。”)

在 Python 中處理字符的另一種方法是使用 chr() 函數。 此函數將整數作為輸入並返回與該數字對應的字符。 例如,以下代碼在屏幕上打印字母“a”:

print(“字符‘a’是”)
字符(1)

文本和對象

在 Python 中,文本由一系列 Unicode 字符表示。 對像也是 Unicode 字符序列,但它們也可以包含其他數據類型,例如數字和字符串。

相關文章:

發表評論