<｜begin▁of▁sentence｜>### Instruction:
Given the High-energy theory collaborations graph which you can read from a GML file named hep-th.gml, can you use the spectral function in cdlib to perform community detection with a maximum of 2 desired communities? After detecting the communities, can you convert the communities' structure into a JSON format?
### Response:
import networkx as nx
from cdlib import algorithms

# Load the High-energy theory collaborations graph
G = nx.read_gml('hep-th.gml')

# Perform Spectral Clustering on the graph
coms = algorithms.spectral(G, kmax=2)

# Convert the communities to JSON
coms_json = coms.to_json()

print(coms_json)
<|EOT|>
