objects get resized after sound baking

I used this guide to make a audio visualizer. for some reason the objects that are generated get resized after the audio is baked.

here’s the script I used:

import bpy
import pprint

for i in range(0, 40):
    bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=((i/2)-9.75, 0, 0))
    ob = bpy.context.active_object
    #sets origin to bottom of object
    bpy.context.scene.cursor_location = bpy.context.active_object.location
    bpy.context.scene.cursor_location.y -= 1

    bpy.ops.transform.resize(value=(0.2, 0.2, 0.2))
    #Insert a scaling keyframe and lock the x and z axis
    bpy.context.active_object.animation_data.action.fcurves[0].lock = True
    bpy.context.active_object.animation_data.action.fcurves[2].lock = True
    #Set the window context to the graph editor
    bpy.context.area.type = 'GRAPH_EDITOR'
    #Expression to determine the frequency range of the bars
    l = i**2 + 20
    h = (i+1)**2 + 20
    #Bake that range of frequencies to the current plane (along the y axis)
    bpy.ops.graph.sound_bake(filepath=r'C:\Users\andga\Desktop\Garrett\Music\Knife Party\Singles & EP\2012 - Rage Valley\01-knife_party-rage_valley.mp3', low = (l), high = (h))
    #Lock the y axis
    bpy.context.active_object.animation_data.action.fcurves[1].lock = True
    ob = bpy.context.active_object
    mat = bpy.data.materials["white"]

EDIT: I needed to replace “bpy.ops.transform.resize(value=(0.2, 0.2, 0.2))” with “ob.scale = (0.2, 0.2, 0.2)”
it was rescaling the original cube over and over instead of rescaling the most recently created cube.