You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
805 B
Python
24 lines
805 B
Python
from pathlib import Path
|
|
from flask_restx import Namespace, Resource, fields
|
|
|
|
api = Namespace('synthesizers', description='Synthesizers related operations')
|
|
|
|
synthesizer = api.model('Synthesizer', {
|
|
'name': fields.String(required=True, description='The synthesizer name'),
|
|
'path': fields.String(required=True, description='The synthesizer path'),
|
|
})
|
|
|
|
synthesizers_cache = {}
|
|
syn_models_dirt = "synthesizer/saved_models"
|
|
synthesizers = list(Path(syn_models_dirt).glob("**/*.pt"))
|
|
print("Loaded synthesizer models: " + str(len(synthesizers)))
|
|
|
|
@api.route('/')
|
|
class SynthesizerList(Resource):
|
|
@api.doc('list_synthesizers')
|
|
@api.marshal_list_with(synthesizer)
|
|
def get(self):
|
|
'''List all synthesizers'''
|
|
return list({"name": e.name, "path": str(e)} for e in synthesizers)
|
|
|