mirror of
https://github.com/babysor/MockingBird.git
synced 2024-03-22 13:11:31 +08:00
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)
|
|
|