Commit ab643b9b authored by Matteo's avatar Matteo
Browse files

refactor with mpai-cae-arp package

parent ad23b303
venv
__pycache__
config.yaml
\ No newline at end of file
__pycache__
\ No newline at end of file
......@@ -10,4 +10,4 @@ RUN pip install --no-cache-dir -r requirements.txt
VOLUME [ "/data" ]
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "80", "--log-config", "log_config.yaml"]
CMD ["uvicorn", "src.server:app", "--host", "0.0.0.0", "--port", "80", "--log-config", "config/logger.yaml"]
anyio==3.6.2
appdirs==1.4.4
audioread==3.0.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.3
contourpy==1.0.7
control==0.9.3.post2
cycler==0.11.0
decorator==5.1.1
dnspython==2.3.0
email-validator==1.3.1
fastapi==0.95.0
......@@ -15,26 +20,41 @@ httpx==0.23.3
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
joblib==1.2.0
kiwisolver==1.4.4
lazy_loader==0.2
librosa==0.10.0.post2
llvmlite==0.39.1
MarkupSafe==2.1.2
matplotlib==3.7.1
numpy==1.23.5
mpai-cae-arp==0.1.0
msgpack==1.0.5
numba==0.56.4
numpy==1.23.3
orjson==3.8.9
packaging==23.0
Pillow==9.5.0
pooch==1.6.0
pycparser==2.21
pydantic==1.10.7
pyparsing==3.0.9
python-dateutil==2.8.2
python-dotenv==1.0.0
python-multipart==0.0.6
PyYAML==6.0
requests==2.28.2
rfc3986==1.5.0
scikit-learn==1.2.2
scipy==1.10.0
six==1.16.0
sniffio==1.3.0
soundfile==0.12.1
soxr==0.3.4
starlette==0.26.1
threadpoolctl==3.1.0
typing_extensions==4.5.0
ujson==5.7.0
urllib3==1.26.15
uvicorn==0.21.1
uvloop==0.17.0
watchfiles==0.19.0
......
import subprocess
import json
import yaml
from fastapi import FastAPI, Response, status
from tapeAudioRestoration import __author__, __version__, __license__, __email__, __maintainer__
from mpai_cae_arp.types.schema import Info
from mpai_cae_arp.files import get_file_content
app = FastAPI(
from src.tapeAudioRestoration import __author__, __version__, __license__, __email__, __maintainer__
info = Info(
title="Tape Audio Restoration",
description="""
[![MPAI CAE-ARP](https://img.shields.io/badge/MPAI%20CAE--ARP-gray?style=for-the-badge&logo=AppleMusic&logoColor=cyan&link=https://mpai.community/standards/mpai-cae/about-mpai-cae/)](https://mpai.community/standards/mpai-cae/about-mpai-cae/)
......@@ -19,15 +21,21 @@ Implements the Technical Specification of [MPAI CAE-ARP](https://mpai.community/
"name": __maintainer__,
"email": __email__
},
license_info={
"name": __license__,
}
license_info={"name": __license__, "url": "https://www.gnu.org/licenses/gpl-3.0.html"}
)
app = FastAPI(**(json.loads(info.json())))
@app.get("/")
def index():
return {"endpoints": ["restore", "docs"]}
def list_all_entrypoints() -> list[str]:
return ["restore", "description", "docs"]
@app.get("/description")
async def get_server_info() -> Info:
return info
@app.get("/restore", status_code=200)
......@@ -35,7 +43,7 @@ async def restore(files_name: str, equalization_w: str, equalization_r: str, spe
process = [
"python",
"tapeAudioRestoration.py",
"src/tapeAudioRestoration.py",
"--files_name", files_name,
"--equalization-w", equalization_w,
"--equalization-r", equalization_r,
......@@ -46,17 +54,15 @@ async def restore(files_name: str, equalization_w: str, equalization_r: str, spe
if working_path is not None:
process.extend(["--working_path", working_path])
else:
with open("config.yaml") as yaml_file:
config = yaml.safe_load(yaml_file)
process.extend(["--working_path", config["WorkingPath"]])
config = get_file_content("config/args.yaml", "yaml")
process.extend(["--working_path", config["WORKING_PATH"]])
cprocess = subprocess.run(process, capture_output=True)
if cprocess.returncode == 0:
with open('EditingList.json') as json_file:
editing_list = json.load(json_file)
editing_list = get_file_content("EditingList.json", "json")
return editing_list
else:
......
......@@ -20,6 +20,7 @@ from control import c2d, TransferFunction
from numpy import ndarray
from scipy.io import wavfile
from scipy.signal import tf2zpk, zpk2tf, lfilter
from mpai_cae_arp.io import Color, Style, prettify
__author__ = "Nadir Dalla Pozza"
__copyright__ = "Copyright 2022, Audio Innova S.r.l."
......@@ -116,9 +117,9 @@ def get_arguments() -> tuple[str, str, str, float, str, float]:
# Read configuration file
config = object
try:
config = yaml.safe_load(open('config.yaml', 'r'))
config = yaml.safe_load(open('config/args.yaml', 'r'))
if 'WORKING_PATH' not in config:
print(CC.RED + 'WORKING_PATH key not found in config.yaml!' + CC.END)
print(prettify('WORKING_PATH key not found in config/args.yaml!', color=Color.RED))
quit(os.EX_CONFIG)
if 'FILES_NAME' not in config:
print(CC.RED + 'FILES_NAME key not found in config.yaml!' + CC.END)
......@@ -136,7 +137,7 @@ def get_arguments() -> tuple[str, str, str, float, str, float]:
print(CC.RED + 'SPEED_R key not found in config.yaml!' + CC.END)
quit(os.EX_CONFIG)
except FileNotFoundError:
print(CC.RED + 'config.yaml file not found!' + CC.END)
print(CC.RED + 'config/args.yaml file not found!' + CC.END)
quit(os.EX_NOINPUT)
working_path = config['WORKING_PATH']
files_name = config['FILES_NAME']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment