I am trying to reduce noise in my audio_file and want to have an output file which doesn't contain noise, and I use the logmmse library:
I use this code:
import wavio
import numpy as np
from logmmse import logmmse_from_file
import logmmse
r = wavio.read('03-01-02-02-01-01-01(read).wav')
y,sr = librosa.load('03-01-02-02-01-01-01(read).wav')
#print(y)
import numpy as np
A = np.asarray(y)
but I have this error:
TypeError: 'module' object is not callable!
can you help me please?
#print(A)
logmmse(A, r.rate, output_file = 'log.wav')
As the error states, you are trying to call the module itself. I suppose what you're trying to do is use the logmmse function inside the logmmse module, so you should do:
logmmse.logmmse(A, r.rate, output_file = 'log.wav')
Related
I decided to simulate a function in a tutorial and I wonder why I am getting the error "AttributeError: 'numpy.ndarray' object has no attribute 'logpdf'"
import numpy as np
from scipy import stats
pL = stats.norm(loc=-1, scale=1).rvs(5)
pR = stats.norm(loc=1, scale=1).rvs(5)
PT = pL.logpdf(pL) - pL.logpdf(pR)
NumPy has decided not to clear the FP exception after calling fmod.
https://github.com/numpy/numpy/pull/17547#issuecomment-714310892
This is my code.
import sys, os
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from scipy import *
sys.path.insert(0, 'C:/research')
im = Image.open('C:/research/1.jpg')
hei, wei = im.height, im.width
im_bicubic = im.resize((wei,hei), im.BICUBIC)
im.save('C:/research/1ori.jpg') #original image
im_bicubic.save('C:/research/1bic.jpg') #Images with bicubic applied
But I get this error.
AttributeError: 'JpegImageFile' object has no attribute 'BICUBIC'
Why is this message coming up?
.bmp, the same message pops up.
What should I do?
You need to use PIL.Image.BICUBIC instead of im.BICUBIC.
So you need to change:
im_bicubic = im.resize((wei,hei), im.BICUBIC)
to
im.resize((wei,hei),PIL.Image.BICUBIC)
You also need to import pil like so:
import PIL
In my master file I have:
import matplotlib.pyplot as plt
import seaborn
import numpy as np
import time
import sys
sys.path.append("C:/.../python check/createsplit")
import createsplit
data='MJexample'
X,Y,N,Ntr=create_training_data(data)
where I am calling create_training_data function from createsplit.py file which is:
import numpy as np
import scipy.io
def create_training_data(data_type):
"""
creates training data
"""
if data_type=='MJexample':
N=300
Ntr = 150
X=np.linspace(0,1,N)
X = np.array([X,X*X,np.linspace(5,10,N),np.sin(X),np.cos(X),np.sin(X)*np.cos(X)]).T
fac=40
Y=np.array([np.sin(fac*x)*np.cos(fac*x**2) for x in X[:,0]])[:,None]
_X=X
_Y=Y
return _X,_Y,N,Ntr
However running my original file results in error: NameError: global name 'np' is not defined for some reason I do not understand. I assume I am importing the functions in a wrong way but I don't really understand what would be wrong.
I think this issue raises just because of a wrong call of the function. Try
X, Y, N, Ntr = createsplit.create_training_data(data)
instead, and it should work.
I'm trying to extract features using tsfresh package and extract_features() function.
tsfresh Version: 0.4.0.post0.dev1+ng19fa136
However, I get the following error:
AttributeError: type object 'MinimalFeatureExtractionSettings' has no
attribute 'n_processes'
Code:
import numpy as np
import pandas as pd
column_names = ['time_series1', 'time_series2','time_series3']
ts = np.random.rand(6,3)
df_to_extract = pd.DataFrame(data=ts, columns = column_names)
df_to_extract['id'] = 1
df_to_extract['time'] = np.arange(1,7)
#print(df_to_extract)
import tsfresh
from tsfresh import extract_features
from tsfresh import select_features
from tsfresh.utilities.dataframe_functions import impute
from tsfresh import extract_relevant_features
from tsfresh.feature_extraction import extract_features, MinimalFeatureExtractionSettings
from tsfresh.feature_extraction.settings import *
from tsfresh.feature_extraction.settings import FeatureExtractionSettings
import tsfresh.feature_extraction.settings
from tsfresh import utilities
from tsfresh import feature_extraction
extracted_features = extract_features(df_to_extract,
column_id="id",
column_sort="time",
parallelization= 'per_kind',
feature_extraction_settings= MinimalFeatureExtractionSettings)
Package source code: https://github.com/blue-yonder/tsfresh/blob/master/tsfresh/feature_extraction/extraction.py
I'm using Python 3.5 (Anaconda) on Win10.
I suppose it could be some kind of import error.
How to solve that issue?
Problem solved
To make it work add:
settings= MinimalFeatureExtractionSettings()
extracted_features = extract_features(df_to_extract,
column_id="id",
column_sort="time",
parallelization= 'per_kind',
feature_extraction_settings= settings)
There is no MinimalFeatureExtractionSettings object anymore. It is called MinimalFCParameters now. Thus, you would have to write the following code:
from tsfresh.feature_extraction import extract_features, MinimalFCParameters
...
minimalFCParametersForTsFresh = MinimalFCParameters()
extracted_features = extract_features(df_to_extract,column_id="id",default_fc_parameters = minimalFCParametersForTsFresh)
I tried running the following program
import numpy as np
data = np.genfromtxt('data.csv', delimiter = ',')
which gives
AttributeError: 'module' object has no attribute 'genfromtxt'
Help much appreciated
You must import matplotlib and it will work
copy and past next code
import numpy as np
from matplotlib import pyplot as plt
data = np.genfromtxt('data.csv', delimiter = ',')