# How to keyframe the volume of a speaker with python

one can set the keyframe of an objects location with:

bpy.context.object.keyframe_insert(data_path="location", frame=1)


and it will set the keyframe of the location. Right now I'm trying to add a keyframe to a newly added speaker that I created with python:

NewSpeaker = bpy.ops.object.speaker_add(location=(0,0,0))


following that I change the speakers volume:

bpy.context.object.data.volume = 0.6


this does work propperly and with no issue, so when trying to keyframe the volume like this:

bpy.context.object.keyframe_insert(data_path="volume", frame=1)


I receive the following error message:

TypeError: bpy_struct.keyframe() property "volume" not found


It does work with things such as location or rotation_euler, but nothing in the Object Data Properties.

Things such volume min are not able to have keyframes, but volume and pitch are able to be keyframed.

Is there a way to keyframe the volume with python?

obj.keyframe_insert("volume")

obj.data.keyframe_insert("volume")