Open wei17hao10 opened 10 months ago
Hello, 1 - Find where the files have been installed. The easiest way to find the project folder is currently to de-install pianoputer, without actually removing it (press no)
As shown in the image above the project folder will be displayed.
use a command prompt to go to that location
In this example it will be something like c:\users.....\appdata\roaming\python\python311\scripts\
This folder will be different for each users and the location might also be in the window Program file
folder depends if
you installed Python for all users or not.
So change the path accordingly
C:\>cd c:\users\yoyob\appdata\roaming\python\python311\scripts\
2 - type the following to get to the source file
cd ../site-packages/pianoputer
Once you are in the right folder and can see the file pianoputer.py edit the file with Python or any other text editor and do the following changes e.g:
notepad pianoputer.py
At line 103 and line 106 in file pianoputer.py Change
if channels == 1:
sound = librosa.effects.pitch_shift(y, sr, n_steps=tone)
else:
new_channels = [
librosa.effects.pitch_shift(y[i], sr, n_steps=tone)
for i in range(channels)
]
to
if channels == 1:
print(y, len(y))
sound = librosa.effects.pitch_shift(y=y, sr=sr, n_steps=tone)
else:
new_channels = [
librosa.effects.pitch_shift(y=y[i], sr=sr, n_steps=tone)
for i in range(channels)
]
Then run the source code
python pianoputer.py
Once this has been changed into the project source code and reloaded to PIP pianoputer
will works without applying this fix
def pitch(data, sampling_rate, pitch_factor=0.7): return librosa.effects.pitch_shift(data, sampling_rate, pitch_factor=pitch_factor)
def get_features(path):
data, sample_rate = librosa.load(path, duration=2.5, offset=0.6)
res1 = extract_features(data,sample_rate) result = np.array(res1)
noise_data = noise(data) res2 = extract_features(noise_data,sample_rate) result = np.vstack((result, res2))
new_data = stretch(data) data_stretch_pitch = pitch(new_data, sample_rate) res3 = extract_features(data_stretch_pitch,sample_rate) result = np.vstack((result, res3))
return result
when i call this function from get_features this gives the error "TypeError: pitch_shift() takes 1 positional argument but 2 were given" Anyone plz help
hello, can you provide the method extract_features
?
This method is missing from your code and I cannot reproduce without it
Also worse changing the method from
def pitch(data, sampling_rate, pitch_factor=0.7):
return librosa.effects.pitch_shift(data, sampling_rate, pitch_factor=pitch_factor)
to
def pitch(data, sampling_rate, pitch_factor=0.7):
return librosa.effects.pitch_shift(data, sampling_rate, n_steps=pitch_factor)
Kind Regards
Thank you for this helpful information
On Fri, Jun 21, 2024 at 11:18 PM Yoann Berenguer @.***> wrote:
hello, can you provide the method extract_features? This method is missing from your code and I cannot reproduce without it Also worse changing the method from
def pitch(data, sampling_rate, pitch_factor=0.7): return librosa.effects.pitch_shift(data, sampling_rate, pitch_factor=pitch_factor)
to
def pitch(data, sampling_rate, pitch_factor=0.7): return librosa.effects.pitch_shift(data, sampling_rate, n_steps=pitch_factor)
Kind Regards
— Reply to this email directly, view it on GitHub https://github.com/Zulko/pianoputer/issues/31#issuecomment-2183183128, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJKWNPNQDHBM6IGNEMGSHDLZIRRQJAVCNFSM6AAAAABJT3JVOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBTGE4DGMJSHA . You are receiving this because you commented.Message ID: @.***>
(v3_8) PS C:\Users\WeiHao\PycharmProjects\pianoputer> pianoputer pygame 2.5.1 (SDL 2.28.2, Python 3.8.17) Hello from the pygame community. https://www.pygame.org/contribute.html Generating samples for each key Transposing note 1 out of 43 for Key.BACKQUOTE Traceback (most recent call last): File "C:\Users\WeiHao.conda\envs\v3_8\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\WeiHao.conda\envs\v3_8\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\WeiHao.conda\envs\v3_8\Scripts\pianoputer.exe__main__.py", line 7, in
File "C:\Users\WeiHao.conda\envs\v3_8\lib\site-packages\pianoputer\pianoputer.py", line 345, in play_pianoputer
key_sounds = get_or_create_key_sounds(
File "C:\Users\WeiHao.conda\envs\v3_8\lib\site-packages\pianoputer\pianoputer.py", line 102, in get_or_create_key_sounds
sound = librosa.effects.pitch_shift(y, sr, n_steps=tone)
TypeError: pitch_shift() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given