I was able to use your script to convert to gltf.
These are the changes I made to make it work.
gltf_name = file_name+".gltf"
...
#Saving file as .glb
bpy.ops.export_scene.gltf(filepath=export_dir+"/"+gltf_name, export_format='GLTF_SEPARATE')