Spaces:
Sleeping
Sleeping
| import subprocess | |
| from fastapi import FastAPI | |
| app = FastAPI() | |
| def greet_json(): | |
| return {"Hello": "World!"} | |
| 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} | |
| def show(): | |
| resultado = subprocess.run(["ls", "midi-emotion/output/models/discrete_token"]) | |
| print(resultado) | |
| return {} |