File size: 1,196 Bytes
1c6b6d5
d34c28a
 
 
 
 
 
 
314d1c2
 
 
5792771
21aaf71
 
 
 
9aafbba
 
1c392a4
21aaf71
 
 
 
 
 
 
 
 
 
 
 
5d6666c
 
b72e3b4
 
 
 
af911a4
b72e3b4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import subprocess
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def greet_json():
    return {"Hello": "World!"}


@app.get("/generate")
def generate(arousal: float, valence: float):
    try:
        resultado = subprocess.run(
            [
                'python',
                'midi-emotion/src/generate.py',
                '--model_dir', 'models/discrete_token',
                '--output_dir', 'midi-emotion/output',
                '--conditioning', 'discrete_token',
                '--valence', str(valence),
                '--arousal', str(arousal),
                '--min_n_instruments', str(1),
                '--batch_size', '1',
                '--gen_len', str(64),
                '--penalty_coeff', '-1'
            ],
            capture_output=True,  # Capture stdout and stderr
            text=True,            # Decode output as text
            check=True            # Raise an exception if the command fails
        )
    except Exception as e:
        resultado = e
    return {"resultado": resultado}

@app.get("/show")
def show():
    resultado = subprocess.run(["ls", "midi-emotion/output/models/discrete_token"])
    print(resultado)
    return {}