Code not working


So I’m trying to sync music to an animation and thought the Librosa addon would work. However, despite the code being the same as the tutorial it’s not working. (despite, Librosa being downloaded into Blender it won’t recognize it when running)

Hello, please post the code as text, not as an image, also can you copy/paste the error ? What exactly does not work ? What should it do ? What is y, sr librosa.load(input_file) supposed to do ?

2 Likes

First of all: I agree with the previous post. Please share the code as code and not as picture.

What do you mean by “librosa downloaded in Blender”? Did you just download it and copy it somewhere or did you follow proper Python installation routines (e.g. explained here: https://stackoverflow.com/questions/11161901/how-to-install-python-modules-in-blender).

I do not know librosa, but for my own plugins I install many packages that do not come with Blender and never faced any problems if things are done in the Python way.

1 Like

Line 6: Not imput_file,
but input_file

import bpy
import os
import math
import librosa

input_file = r"File Name"

y, sr librosa.load(imput_file) #<- error is bolded
onset_frames = librosa.load(imput_file)
onset_times = librosa.frames_to_time(onset_frames)

fps = bpy.context.scene.render.fps
scene = bpy.context.secene
scene.timeline_markers.clear()

obj = bpy.data.objects[‘Cube’]

for idx, onset_time in enumerate(onset_times):
frame=math.ceil(onset_time * fps)
scene.timeline_markers.new(‘F_’+str(idx), frame=frame)

The tutorial I used is this https://youtu.be/uzd7wd72LdQ
What I mean by “librosa downloaded in Blender” is that there was code that I ran in order to download it, and it was successful. (code for that is provided in the tutorial.
P.S I am sorry for responding late I was occupied.

Hello, please read character per character what appears on the image below and type exactly what is written below. You managed to make 2 errors in a single line. I can spot another one a few lines down.

We can help you debug a bug in your code but we can’t type it for you. I’m sorry to say the problem lies between the keyboard and the chair. I very humbly suggest you maybe turn off the podcast you’re listening to while copying the script and actively concentrate, coding is a creative process and needs your entire attention.

Cheers

1 Like

I think I fixed it.