Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
MPAI-Private
MPAI-CAE
arp
Tape Audio Restoration
Commits
d4767d38
Commit
d4767d38
authored
Apr 24, 2023
by
Matteo
Browse files
refactor to pythonic package
parent
da5c2d12
Changes
11
Hide whitespace changes
Inline
Side-by-side
.editorconfig
0 → 100644
View file @
d4767d38
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
\ No newline at end of file
config/args.yaml
→
.env
View file @
d4767d38
# Working path
WORKING_PATH
:
"
/data"
WORKING_PATH
="..
/data"
# Name of the Preservation Audio File (without extension)
FILES_NAME
:
"
sample12_W7N_R15C
"
FILES_NAME
="BERIO100
"
# PRESERVATION_FILE_NAME: "BornToDie"
# PRESERVATION_FILE_NAME: ""
# Equalisation standard used to record the tape.
# Accepted values: ("NAB", "CCIR")
STANDARD_W
:
"
NAB"
STANDARD_W
=
"NAB"
# Recording tape speed [ips].
# Accepted values: (3.75, 7.5, 15, 30)
SPEED_W
:
7.
5
SPEED_W
=1
5
# Equalization standard used to read the tape.
# Accepted values: ("NAB", "CCIR")
STANDARD_R
:
"
CCIR
"
STANDARD_R
="NAB
"
# Reading tape speed [ips].
# Accepted values: (3.75, 7.5, 15, 30)
SPEED_R
:
15
\ No newline at end of file
SPEED_R=15
\ No newline at end of file
config
/server
.y
a
ml
→
config.yml
View file @
d4767d38
File moved
config/logger.yaml
deleted
100644 → 0
View file @
da5c2d12
version
:
1
formatters
:
brief
:
format
:
'
%(message)s'
precise
:
format
:
'
[%(levelname)s
%(name)s
%(module)s:%(lineno)s
-
%(funcName)s()
-
%(asctime)s]\n\t
%(message)s
\n'
datefmt
:
'
%d/%m/%Y
%H:%M:%S'
handlers
:
file
:
class
:
logging.handlers.RotatingFileHandler
formatter
:
precise
filename
:
/var/log/tape-audio-restoration/server.log
maxBytes
:
10485760
backupCount
:
3
console
:
class
:
logging.StreamHandler
formatter
:
brief
loggers
:
uvicorn
:
level
:
INFO
handlers
:
[
file
,
console
]
propagate
:
no
\ No newline at end of file
poetry.lock
View file @
d4767d38
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "anyio"
version = "3.6.2"
description = "High level compatibility layer for multiple asynchronous event loop implementations"
category = "main"
optional = false
python-versions = ">=3.6.2"
files = [
{file = "anyio-3.6.2-py3-none-any.whl", hash = "sha256:fbbe32bd270d2a2ef3ed1c5d45041250284e31fc0a4df4a5a6071842051a51e3"},
{file = "anyio-3.6.2.tar.gz", hash = "sha256:25ea0d673ae30af41a0c442f81cf3b38c7e79fdc7b60335a4c14e05eb0947421"},
]
[package.dependencies]
idna = ">=2.8"
sniffio = ">=1.1"
[package.extras]
doc = ["packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"]
test = ["contextlib2", "coverage[toml] (>=4.5)", "hypothesis (>=4.0)", "mock (>=4)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (<0.15)", "uvloop (>=0.15)"]
trio = ["trio (>=0.16,<0.22)"]
[[package]]
name = "appdirs"
version = "1.4.4"
...
...
@@ -218,33 +197,6 @@ files = [
{file = "charset_normalizer-3.1.0-py3-none-any.whl", hash = "sha256:3d9098b479e78c85080c98e1e35ff40b4a31d8953102bb0fd7d1b6f8a2111a3d"},
]
[[package]]
name = "click"
version = "8.1.3"
description = "Composable command line interface toolkit"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
{file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
]
[package.dependencies]
colorama = {version = "*", markers = "platform_system == \"Windows\""}
[[package]]
name = "colorama"
version = "0.4.6"
description = "Cross-platform colored terminal text."
category = "main"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
files = [
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
]
[[package]]
name = "contourpy"
version = "1.0.7"
...
...
@@ -366,28 +318,6 @@ files = [
{file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"},
]
[[package]]
name = "fastapi"
version = "0.95.0"
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "fastapi-0.95.0-py3-none-any.whl", hash = "sha256:daf73bbe844180200be7966f68e8ec9fd8be57079dff1bacb366db32729e6eb5"},
{file = "fastapi-0.95.0.tar.gz", hash = "sha256:99d4fdb10e9dd9a24027ac1d0bd4b56702652056ca17a6c8721eec4ad2f14e18"},
]
[package.dependencies]
pydantic = ">=1.6.2,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0"
starlette = ">=0.26.1,<0.27.0"
[package.extras]
all = ["email-validator (>=1.1.1)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "python-multipart (>=0.0.5)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"]
dev = ["pre-commit (>=2.17.0,<3.0.0)", "ruff (==0.0.138)", "uvicorn[standard] (>=0.12.0,<0.21.0)"]
doc = ["mdx-include (>=1.4.1,<2.0.0)", "mkdocs (>=1.1.2,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "pyyaml (>=5.3.1,<7.0.0)", "typer-cli (>=0.0.13,<0.0.14)", "typer[all] (>=0.6.1,<0.8.0)"]
test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==23.1.0)", "coverage[toml] (>=6.5.0,<8.0)", "databases[sqlite] (>=0.3.2,<0.7.0)", "email-validator (>=1.1.1,<2.0.0)", "flask (>=1.1.2,<3.0.0)", "httpx (>=0.23.0,<0.24.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.982)", "orjson (>=3.2.1,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "pytest (>=7.1.3,<8.0.0)", "python-jose[cryptography] (>=3.3.0,<4.0.0)", "python-multipart (>=0.0.5,<0.0.7)", "pyyaml (>=5.3.1,<7.0.0)", "ruff (==0.0.138)", "sqlalchemy (>=1.3.18,<1.4.43)", "types-orjson (==3.6.2)", "types-ujson (==5.7.0.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)"]
[[package]]
name = "fonttools"
version = "4.39.3"
...
...
@@ -415,17 +345,123 @@ unicode = ["unicodedata2 (>=15.0.0)"]
woff = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "zopfli (>=0.1.4)"]
[[package]]
name = "
h11
"
version = "
0.1
4.0"
description = "
A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
"
name = "
grpcio
"
version = "
1.5
4.0"
description = "
HTTP/2-based RPC framework
"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"},
{file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"},
{file = "grpcio-1.54.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:a947d5298a0bbdd4d15671024bf33e2b7da79a70de600ed29ba7e0fef0539ebb"},
{file = "grpcio-1.54.0-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:e355ee9da9c1c03f174efea59292b17a95e0b7b4d7d2a389265f731a9887d5a9"},
{file = "grpcio-1.54.0-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:73c238ef6e4b64272df7eec976bb016c73d3ab5a6c7e9cd906ab700523d312f3"},
{file = "grpcio-1.54.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c59d899ee7160638613a452f9a4931de22623e7ba17897d8e3e348c2e9d8d0b"},
{file = "grpcio-1.54.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:48cb7af77238ba16c77879009003f6b22c23425e5ee59cb2c4c103ec040638a5"},
{file = "grpcio-1.54.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:2262bd3512ba9e9f0e91d287393df6f33c18999317de45629b7bd46c40f16ba9"},
{file = "grpcio-1.54.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:224166f06ccdaf884bf35690bf4272997c1405de3035d61384ccb5b25a4c1ca8"},
{file = "grpcio-1.54.0-cp310-cp310-win32.whl", hash = "sha256:ed36e854449ff6c2f8ee145f94851fe171298e1e793f44d4f672c4a0d78064e7"},
{file = "grpcio-1.54.0-cp310-cp310-win_amd64.whl", hash = "sha256:27fb030a4589d2536daec5ff5ba2a128f4f155149efab578fe2de2cb21596d3d"},
{file = "grpcio-1.54.0-cp311-cp311-linux_armv7l.whl", hash = "sha256:f4a7dca8ccd8023d916b900aa3c626f1bd181bd5b70159479b142f957ff420e4"},
{file = "grpcio-1.54.0-cp311-cp311-macosx_10_10_universal2.whl", hash = "sha256:1209d6b002b26e939e4c8ea37a3d5b4028eb9555394ea69fb1adbd4b61a10bb8"},
{file = "grpcio-1.54.0-cp311-cp311-manylinux_2_17_aarch64.whl", hash = "sha256:860fcd6db7dce80d0a673a1cc898ce6bc3d4783d195bbe0e911bf8a62c93ff3f"},
{file = "grpcio-1.54.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3930669c9e6f08a2eed824738c3d5699d11cd47a0ecc13b68ed11595710b1133"},
{file = "grpcio-1.54.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:62117486460c83acd3b5d85c12edd5fe20a374630475388cfc89829831d3eb79"},
{file = "grpcio-1.54.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:e3e526062c690517b42bba66ffe38aaf8bc99a180a78212e7b22baa86902f690"},
{file = "grpcio-1.54.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ebff0738be0499d7db74d20dca9f22a7b27deae31e1bf92ea44924fd69eb6251"},
{file = "grpcio-1.54.0-cp311-cp311-win32.whl", hash = "sha256:21c4a1aae861748d6393a3ff7867473996c139a77f90326d9f4104bebb22d8b8"},
{file = "grpcio-1.54.0-cp311-cp311-win_amd64.whl", hash = "sha256:3db71c6f1ab688d8dfc102271cedc9828beac335a3a4372ec54b8bf11b43fd29"},
{file = "grpcio-1.54.0-cp37-cp37m-linux_armv7l.whl", hash = "sha256:960b176e0bb2b4afeaa1cd2002db1e82ae54c9b6e27ea93570a42316524e77cf"},
{file = "grpcio-1.54.0-cp37-cp37m-macosx_10_10_universal2.whl", hash = "sha256:d8ae6e0df3a608e99ee1acafaafd7db0830106394d54571c1ece57f650124ce9"},
{file = "grpcio-1.54.0-cp37-cp37m-manylinux_2_17_aarch64.whl", hash = "sha256:c33744d0d1a7322da445c0fe726ea6d4e3ef2dfb0539eadf23dce366f52f546c"},
{file = "grpcio-1.54.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1d109df30641d050e009105f9c9ca5a35d01e34d2ee2a4e9c0984d392fd6d704"},
{file = "grpcio-1.54.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:775a2f70501370e5ba54e1ee3464413bff9bd85bd9a0b25c989698c44a6fb52f"},
{file = "grpcio-1.54.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:c55a9cf5cba80fb88c850915c865b8ed78d5e46e1f2ec1b27692f3eaaf0dca7e"},
{file = "grpcio-1.54.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:1fa7d6ddd33abbd3c8b3d7d07c56c40ea3d1891ce3cd2aa9fa73105ed5331866"},
{file = "grpcio-1.54.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ed3d458ded32ff3a58f157b60cc140c88f7ac8c506a1c567b2a9ee8a2fd2ce54"},
{file = "grpcio-1.54.0-cp38-cp38-linux_armv7l.whl", hash = "sha256:5942a3e05630e1ef5b7b5752e5da6582460a2e4431dae603de89fc45f9ec5aa9"},
{file = "grpcio-1.54.0-cp38-cp38-macosx_10_10_universal2.whl", hash = "sha256:125ed35aa3868efa82eabffece6264bf638cfdc9f0cd58ddb17936684aafd0f8"},
{file = "grpcio-1.54.0-cp38-cp38-manylinux_2_17_aarch64.whl", hash = "sha256:b7655f809e3420f80ce3bf89737169a9dce73238af594049754a1128132c0da4"},
{file = "grpcio-1.54.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:87f47bf9520bba4083d65ab911f8f4c0ac3efa8241993edd74c8dd08ae87552f"},
{file = "grpcio-1.54.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:16bca8092dd994f2864fdab278ae052fad4913f36f35238b2dd11af2d55a87db"},
{file = "grpcio-1.54.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:d2f62fb1c914a038921677cfa536d645cb80e3dd07dc4859a3c92d75407b90a5"},
{file = "grpcio-1.54.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:a7caf553ccaf715ec05b28c9b2ab2ee3fdb4036626d779aa09cf7cbf54b71445"},
{file = "grpcio-1.54.0-cp38-cp38-win32.whl", hash = "sha256:2585b3c294631a39b33f9f967a59b0fad23b1a71a212eba6bc1e3ca6e6eec9ee"},
{file = "grpcio-1.54.0-cp38-cp38-win_amd64.whl", hash = "sha256:3b170e441e91e4f321e46d3cc95a01cb307a4596da54aca59eb78ab0fc03754d"},
{file = "grpcio-1.54.0-cp39-cp39-linux_armv7l.whl", hash = "sha256:1382bc499af92901c2240c4d540c74eae8a671e4fe9839bfeefdfcc3a106b5e2"},
{file = "grpcio-1.54.0-cp39-cp39-macosx_10_10_universal2.whl", hash = "sha256:031bbd26656e0739e4b2c81c172155fb26e274b8d0312d67aefc730bcba915b6"},
{file = "grpcio-1.54.0-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:a97b0d01ae595c997c1d9d8249e2d2da829c2d8a4bdc29bb8f76c11a94915c9a"},
{file = "grpcio-1.54.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:533eaf5b2a79a3c6f35cbd6a095ae99cac7f4f9c0e08bdcf86c130efd3c32adf"},
{file = "grpcio-1.54.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49eace8ea55fbc42c733defbda1e4feb6d3844ecd875b01bb8b923709e0f5ec8"},
{file = "grpcio-1.54.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:30fbbce11ffeb4f9f91c13fe04899aaf3e9a81708bedf267bf447596b95df26b"},
{file = "grpcio-1.54.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:650f5f2c9ab1275b4006707411bb6d6bc927886874a287661c3c6f332d4c068b"},
{file = "grpcio-1.54.0-cp39-cp39-win32.whl", hash = "sha256:02000b005bc8b72ff50c477b6431e8886b29961159e8b8d03c00b3dd9139baed"},
{file = "grpcio-1.54.0-cp39-cp39-win_amd64.whl", hash = "sha256:6dc1e2c9ac292c9a484ef900c568ccb2d6b4dfe26dfa0163d5bc815bb836c78d"},
{file = "grpcio-1.54.0.tar.gz", hash = "sha256:eb0807323572642ab73fd86fe53d88d843ce617dd1ddf430351ad0759809a0ae"},
]
[package.extras]
protobuf = ["grpcio-tools (>=1.54.0)"]
[[package]]
name = "grpcio-tools"
version = "1.54.0"
description = "Protobuf code generator for gRPC"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "grpcio-tools-1.54.0.tar.gz", hash = "sha256:df79acbf59997018e131713b716a2fddb5556e1840e9fb9de4ca73bf2059590e"},
{file = "grpcio_tools-1.54.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:7abdefb364de75d13d929093e571b84c4ea2580dbf5e4b6f5099ac9fa1a93f29"},
{file = "grpcio_tools-1.54.0-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:66738bc9d7b5db1a86832fa930cdd8faaf0c68bf70751d930c686d6bb309fad0"},
{file = "grpcio_tools-1.54.0-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:de07f7441e2f318a68631626d4d99c22244901ad7451a3e9fa08e5601a54772f"},
{file = "grpcio_tools-1.54.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fb6774907a708079afb3deecdd8e053d2b2b066c279a5d8c4957687db3f809ce"},
{file = "grpcio_tools-1.54.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7615b824132fcea4769d0cd99bdeffe25b096b48215c36675f37f7b57dc09635"},
{file = "grpcio_tools-1.54.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:22b826b1d0d98a3bb80094928e21c48e23d022168e91d466a21389d1cda87177"},
{file = "grpcio_tools-1.54.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c03ceec6441365ec56c7fc6f38386917814ad02144dc1ecf03e13cee45f26389"},
{file = "grpcio_tools-1.54.0-cp310-cp310-win32.whl", hash = "sha256:a61f367a153e3e604b1b59cec2f5e61255ffb6328d7348a53531e90ad98cc4fd"},
{file = "grpcio_tools-1.54.0-cp310-cp310-win_amd64.whl", hash = "sha256:8a91f973b44fc90c32b7df79daec78907f0721e65d85fdff9133e05fee1f6e56"},
{file = "grpcio_tools-1.54.0-cp311-cp311-linux_armv7l.whl", hash = "sha256:436335857731e8f0bc5d345804d7dcd1bc677a1f793ea2b22e0627870ea31df6"},
{file = "grpcio_tools-1.54.0-cp311-cp311-macosx_10_10_universal2.whl", hash = "sha256:9fa42e3851c3c795228e2699c68ff7db14789991da4b53d3634360a361e0e420"},
{file = "grpcio_tools-1.54.0-cp311-cp311-manylinux_2_17_aarch64.whl", hash = "sha256:7ab23a94a8a7aa97ad8f46ba39ade4462c19833aa4815780db2cec647df7efef"},
{file = "grpcio_tools-1.54.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:12c3091ef09df47c20d698dc74a373c1674c67ac5ac12ef24433002165129556"},
{file = "grpcio_tools-1.54.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:536c108ee8fa46b1ca8d03f4033cdf282741978f3f83dcc8b2a9e7a2b8197271"},
{file = "grpcio_tools-1.54.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:a66baf974aa00542ba4b6be499266ef8d63aa1abe7c78abab168bdf2fcd7f216"},
{file = "grpcio_tools-1.54.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:b944c1654b5f0710e782c0e3462d7acca900cbf2fb874d62e51a5279293151a9"},
{file = "grpcio_tools-1.54.0-cp311-cp311-win32.whl", hash = "sha256:f5aaa7e90e0947aec936e02fb85f312ca03c2258f3ee78403dcc27389fc62838"},
{file = "grpcio_tools-1.54.0-cp311-cp311-win_amd64.whl", hash = "sha256:6ff318cd73b5cbdb16616d093c1c7b340d8d13b5bada2df7fbd873e899eab162"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-linux_armv7l.whl", hash = "sha256:86169076170f835139db7ec8362124cabe8f01050c2a717500a0fcdeb71dc537"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-macosx_10_10_universal2.whl", hash = "sha256:24158db60cdda7c9eb803a9ed033a23b4420fd13ba4c54392d6b396589afb969"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-manylinux_2_17_aarch64.whl", hash = "sha256:58d2cbbf4e40cecd09f4fa6a2c15f7a95ec90f492b4e31469d8c9db981426106"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e15aa21a68cdb66b38db645924a09196cbbf4ad3ce1cf9dbcdf7b245292e380"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:23474a820bdf8126af93724c7f6b23b16d9f3ad4c4bdcb40936ecb7f2be6bcc7"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:8d2d5522d2222879c161479b5c91661cf788a3178f0b7532fd4c3e918e3390c4"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:52b6f78f5601cd080e5456ec24fd960328f9962e9aa4f9f556ec6fd5e4a391bf"},
{file = "grpcio_tools-1.54.0-cp37-cp37m-win_amd64.whl", hash = "sha256:292c0838d4a52ca53a941d197de57efc7f9df548d0619e14680c3e1ebeb33752"},
{file = "grpcio_tools-1.54.0-cp38-cp38-linux_armv7l.whl", hash = "sha256:b1a3aad8a85d408ec925ee63668c2e4f075c96f67fcc3c43366a28f60e25873c"},
{file = "grpcio_tools-1.54.0-cp38-cp38-macosx_10_10_universal2.whl", hash = "sha256:9d9a8d35a898f5c160fdb1ba0f58ada80e8e291cdffd6025f6043228d0832b2f"},
{file = "grpcio_tools-1.54.0-cp38-cp38-manylinux_2_17_aarch64.whl", hash = "sha256:42e8509ae024e8fb4eeab5ed9518c8e88d7f46a56015ae940796fe708d781e9f"},
{file = "grpcio_tools-1.54.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6dd57137706257c39255020fb04322eef6c4043a11fc86042ae22b05167603ca"},
{file = "grpcio_tools-1.54.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8ed6146e08b82caff467ac2af6c41f092212e3b5795687b76dd9219ac8b7186"},
{file = "grpcio_tools-1.54.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:4b32eaf44939c3dfa127bcb6bcf685188a05c1e0f54a7c8ed10770cbe177ca15"},
{file = "grpcio_tools-1.54.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:cca182c9a33dbf52c61a13fd1b98af535e7563bcd9e02e60e9de742d385f2ffb"},
{file = "grpcio_tools-1.54.0-cp38-cp38-win32.whl", hash = "sha256:ce20c3523a4bdb85531e762f45f7c5f5a915e5a8f25db3d58ebb6a8a37290a75"},
{file = "grpcio_tools-1.54.0-cp38-cp38-win_amd64.whl", hash = "sha256:53dc65731a46bc065ad8d717d75d8659763126d1626eacc6f225c0b779ccc350"},
{file = "grpcio_tools-1.54.0-cp39-cp39-linux_armv7l.whl", hash = "sha256:072279c394086ec07af8736f94aa6be671000af143df5f3040500e8cd5de484d"},
{file = "grpcio_tools-1.54.0-cp39-cp39-macosx_10_10_universal2.whl", hash = "sha256:473dbd7005d059d1dc84490eec35699029d629048e7fdd76e31c14fc58a603e5"},
{file = "grpcio_tools-1.54.0-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:22eecfbb85da93405e056f073e339c34f881a3b410800902ae533e475688b1f1"},
{file = "grpcio_tools-1.54.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e0ba9344855b0c617d6df6bfb46ffbc574815c7152afa023e443cce4d5402f55"},
{file = "grpcio_tools-1.54.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:235ea036d56ab9b6e4f235c554cf4680c42bf79352046e8a25829f597ca0d56b"},
{file = "grpcio_tools-1.54.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:adc93f29353377182556e37120985f69f0fccc79ab65a0f24c1cc53075344dd7"},
{file = "grpcio_tools-1.54.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ab45bda18b4931b08d89e490fd920bf654109d1c2e80b037fe9b60ab30fb4d9d"},
{file = "grpcio_tools-1.54.0-cp39-cp39-win32.whl", hash = "sha256:43339122c891110e9ed020974c0fe2bd773d96c184203a62d0973f4cfb007f80"},
{file = "grpcio_tools-1.54.0-cp39-cp39-win_amd64.whl", hash = "sha256:d58528d6ea1835c0d4c34b60152dd29b3c9ab02ad0a8e734de240d54786d8b1e"},
]
[package.dependencies]
grpcio = ">=1.54.0"
protobuf = ">=4.21.6,<5.0dev"
setuptools = "*"
[[package]]
name = "idna"
version = "3.4"
...
...
@@ -614,6 +650,31 @@ files = [
{file = "llvmlite-0.39.1.tar.gz", hash = "sha256:b43abd7c82e805261c425d50335be9a6c4f84264e34d6d6e475207300005d572"},
]
[[package]]
name = "markdown-it-py"
version = "2.2.0"
description = "Python port of markdown-it. Markdown parsing, done right!"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "markdown-it-py-2.2.0.tar.gz", hash = "sha256:7c9a5e412688bc771c67432cbfebcdd686c93ce6484913dccf06cb5a0bea35a1"},
{file = "markdown_it_py-2.2.0-py3-none-any.whl", hash = "sha256:5a35f8d1870171d9acc47b99612dc146129b631baf04970128b568f190d0cc30"},
]
[package.dependencies]
mdurl = ">=0.1,<1.0"
[package.extras]
benchmarking = ["psutil", "pytest", "pytest-benchmark"]
code-style = ["pre-commit (>=3.0,<4.0)"]
compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"]
linkify = ["linkify-it-py (>=1,<3)"]
plugins = ["mdit-py-plugins"]
profiling = ["gprof2dot"]
rtd = ["attrs", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"]
testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"]
[[package]]
name = "matplotlib"
version = "3.7.1"
...
...
@@ -676,19 +737,32 @@ pillow = ">=6.2.0"
pyparsing = ">=2.3.1"
python-dateutil = ">=2.7"
[[package]]
name = "mdurl"
version = "0.1.2"
description = "Markdown URL utilities"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"},
{file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},
]
[[package]]
name = "mpai-cae-arp"
version = "0.
2
.2"
version = "0.
3
.2"
description = "The MPAI CAE-ARP software API"
category = "main"
optional = false
python-versions = ">=3.10,<4.0"
files = [
{file = "mpai_cae_arp-0.
2
.2-py3-none-any.whl", hash = "sha256:
375b20c31c41be083e27448540ca0632d8ced7aca3d917cfd0f16368101a00f0
"},
{file = "mpai_cae_arp-0.
2
.2.tar.gz", hash = "sha256:
6a7e98a7e80aa154f93ab4bad031046ce87b90d7c8bd0a6c2a7bd0bfd8097a3b
"},
{file = "mpai_cae_arp-0.
3
.2-py3-none-any.whl", hash = "sha256:
468db6aaae5a6d54d1460ede6e9a47686d12ab92680a51e14adf14dcba405aac
"},
{file = "mpai_cae_arp-0.
3
.2.tar.gz", hash = "sha256:
e447ee46f6c4ca18dd87e3b94dbf366d3f4852ad5530886fd577df9b8d32b2cd
"},
]
[package.dependencies]
grpcio-tools = ">=1.53.0,<2.0.0"
librosa = ">=0.10.0.post2,<0.11.0"
llvmlite = ">=0.39.1,<0.40.0"
numpy = "1.23.3"
...
...
@@ -963,6 +1037,29 @@ progress = ["tqdm (>=4.41.0,<5.0.0)"]
sftp = ["paramiko (>=2.7.0)"]
xxhash = ["xxhash (>=1.4.3)"]
[[package]]
name = "protobuf"
version = "4.22.3"
description = ""
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "protobuf-4.22.3-cp310-abi3-win32.whl", hash = "sha256:8b54f56d13ae4a3ec140076c9d937221f887c8f64954673d46f63751209e839a"},
{file = "protobuf-4.22.3-cp310-abi3-win_amd64.whl", hash = "sha256:7760730063329d42a9d4c4573b804289b738d4931e363ffbe684716b796bde51"},
{file = "protobuf-4.22.3-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:d14fc1a41d1a1909998e8aff7e80d2a7ae14772c4a70e4bf7db8a36690b54425"},
{file = "protobuf-4.22.3-cp37-abi3-manylinux2014_aarch64.whl", hash = "sha256:70659847ee57a5262a65954538088a1d72dfc3e9882695cab9f0c54ffe71663b"},
{file = "protobuf-4.22.3-cp37-abi3-manylinux2014_x86_64.whl", hash = "sha256:13233ee2b9d3bd9a5f216c1fa2c321cd564b93d8f2e4f521a85b585447747997"},
{file = "protobuf-4.22.3-cp37-cp37m-win32.whl", hash = "sha256:ecae944c6c2ce50dda6bf76ef5496196aeb1b85acb95df5843cd812615ec4b61"},
{file = "protobuf-4.22.3-cp37-cp37m-win_amd64.whl", hash = "sha256:d4b66266965598ff4c291416be429cef7989d8fae88b55b62095a2331511b3fa"},
{file = "protobuf-4.22.3-cp38-cp38-win32.whl", hash = "sha256:f08aa300b67f1c012100d8eb62d47129e53d1150f4469fd78a29fa3cb68c66f2"},
{file = "protobuf-4.22.3-cp38-cp38-win_amd64.whl", hash = "sha256:f2f4710543abec186aee332d6852ef5ae7ce2e9e807a3da570f36de5a732d88e"},
{file = "protobuf-4.22.3-cp39-cp39-win32.whl", hash = "sha256:7cf56e31907c532e460bb62010a513408e6cdf5b03fb2611e4b67ed398ad046d"},
{file = "protobuf-4.22.3-cp39-cp39-win_amd64.whl", hash = "sha256:e0e630d8e6a79f48c557cd1835865b593d0547dce221c66ed1b827de59c66c97"},
{file = "protobuf-4.22.3-py3-none-any.whl", hash = "sha256:52f0a78141078077cfe15fe333ac3e3a077420b9a3f5d1bf9b5fe9d286b4d881"},
{file = "protobuf-4.22.3.tar.gz", hash = "sha256:23452f2fdea754a8251d0fc88c0317735ae47217e0d27bf330a30eec2848811a"},
]
[[package]]
name = "pycparser"
version = "2.21"
...
...
@@ -1028,6 +1125,21 @@ typing-extensions = ">=4.2.0"
dotenv = ["python-dotenv (>=0.10.4)"]
email = ["email-validator (>=1.0.3)"]
[[package]]
name = "pygments"
version = "2.15.1"
description = "Pygments is a syntax highlighting package written in Python."
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "Pygments-2.15.1-py3-none-any.whl", hash = "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1"},
{file = "Pygments-2.15.1.tar.gz", hash = "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c"},
]
[package.extras]
plugins = ["importlib-metadata"]
[[package]]
name = "pyparsing"
version = "3.0.9"
...
...
@@ -1130,6 +1242,25 @@ urllib3 = ">=1.21.1,<1.27"
socks = ["PySocks (>=1.5.6,!=1.5.7)"]
use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
[[package]]
name = "rich"
version = "13.3.4"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
category = "main"
optional = false
python-versions = ">=3.7.0"
files = [
{file = "rich-13.3.4-py3-none-any.whl", hash = "sha256:22b74cae0278fd5086ff44144d3813be1cedc9115bdfabbfefd86400cb88b20a"},
{file = "rich-13.3.4.tar.gz", hash = "sha256:b5d573e13605423ec80bdd0cd5f8541f7844a0e71a13f74cf454ccb2f490708b"},
]
[package.dependencies]
markdown-it-py = ">=2.2.0,<3.0.0"
pygments = ">=2.13.0,<3.0.0"
[package.extras]
jupyter = ["ipywidgets (>=7.5.1,<9)"]
[[package]]
name = "scikit-learn"
version = "1.2.2"
...
...
@@ -1214,14 +1345,14 @@ test = ["asv", "gmpy2", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeo
[[package]]
name = "setuptools"
version = "67.
6
.1"
version = "67.
7
.1"
description = "Easily download, build, install, upgrade, and uninstall Python packages"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "setuptools-67.
6
.1-py3-none-any.whl", hash = "sha256:
e728ca814a823bf7bf60162daf9db95b93d532948c4c0bea762ce62f60189078
"},
{file = "setuptools-67.
6
.1.tar.gz", hash = "sha256:
257de92a9d50a60b8e22abfcbb771571fde0dbf3ec234463212027a4eeecbe9a
"},
{file = "setuptools-67.
7
.1-py3-none-any.whl", hash = "sha256:
6f0839fbdb7e3cfef1fc38d7954f5c1c26bf4eebb155a55c9bf8faf997b9fb67
"},
{file = "setuptools-67.
7
.1.tar.gz", hash = "sha256:
bb16732e8eb928922eabaa022f881ae2b7cdcfaf9993ef1f5e841a96d32b8e0c
"},
]
[package.extras]
...
...
@@ -1241,18 +1372,6 @@ files = [
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
[[package]]
name = "sniffio"
version = "1.3.0"
description = "Sniff out which async library your code is running under"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"},
{file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"},
]
[[package]]
name = "soundfile"
version = "0.12.1"
...
...
@@ -1321,24 +1440,6 @@ numpy = "*"
docs = ["linkify-it-py", "myst-parser", "sphinx", "sphinx-book-theme"]
test = ["pytest"]
[[package]]
name = "starlette"
version = "0.26.1"
description = "The little ASGI library that shines."
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "starlette-0.26.1-py3-none-any.whl", hash = "sha256:e87fce5d7cbdde34b76f0ac69013fd9d190d581d80681493016666e6f96c6d5e"},
{file = "starlette-0.26.1.tar.gz", hash = "sha256:41da799057ea8620e4667a3e69a5b1923ebd32b1819c8fa75634bbe8d8bea9bd"},
]
[package.dependencies]
anyio = ">=3.4.0,<5"
[package.extras]
full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyaml"]
[[package]]
name = "threadpoolctl"
version = "3.1.0"
...
...
@@ -1380,26 +1481,7 @@ brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"]
secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"]
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
[[package]]
name = "uvicorn"
version = "0.21.1"
description = "The lightning-fast ASGI server."
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "uvicorn-0.21.1-py3-none-any.whl", hash = "sha256:e47cac98a6da10cd41e6fd036d472c6f58ede6c5dbee3dbee3ef7a100ed97742"},
{file = "uvicorn-0.21.1.tar.gz", hash = "sha256:0fac9cb342ba099e0d582966005f3fdba5b0290579fed4a6266dc702ca7bb032"},
]
[package.dependencies]
click = ">=7.0"
h11 = ">=0.8"
[package.extras]
standard = ["colorama (>=0.4)", "httptools (>=0.5.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.10,<3.12"
content-hash = "
7e3409309d18ad5eb313ce4948c6a4804306b43333e799d9b82232ce3320aa4a
"
content-hash = "
5a3914f84e608f8a2b21b7010f3ecfc12f268e593396f6c81e1aee89ac022109
"
pyproject.toml
View file @
d4767d38
[tool.poetry]
name
=
"tape-audio-restoration"
version
=
"1.
0.1
"
version
=
"1.
1.0
"
description
=
"MPAI CAE-ARP Tape Audio Restoration."
authors
=
[
"Matteo Spanio <dev2@audioinnova.com>"
,
"Nadir Dalla Pozza <nadir.dallapozza@unipd.it>"
]
authors
=
[
"Matteo Spanio <dev2@audioinnova.com>"
,
"Nadir Dalla Pozza <nadir.dallapozza@unipd.it>"
]
license
=
"GPLv3"
readme
=
"README.md"
packages
=
[
{
include
=
"tape_audio_restoration"
,
from
=
"src"
}
]
[tool.poetry.dependencies]
python
=
">
=
3.10
,
<
3.12
"
numpy
=
"1.23.3"
mpai-cae-arp
=
"^0.2.2"
control
=
"0.9.3.post2"
scipy
=
"^1.10.1"
fastapi
=
{
extras
=
["standard"]
,
version
=
"^0.
95.0"
}
uvicorn
=
"^0.21.1
"
mpai-cae-arp
=
"^0.
3.2"
rich
=
"^13.3.4
"
[build-system]
...
...
@@ -21,4 +24,4 @@ requires = ["poetry-core"]
build-backend
=
"poetry.core.masonry.api"
[tool.poetry.scripts]
tape-audio-restoration
=
'tapeAudioRestoration:main'
\ No newline at end of file
tape-audio-restoration
=
'tape_audio_restoration.cli:main'
\ No newline at end of file
src/server.py
deleted
100644 → 0
View file @
da5c2d12
import
subprocess
from
fastapi
import
FastAPI
,
Response
,
status
,
Query
from
typing
import
Annotated
from
mpai_cae_arp.types.schema
import
Info
from
mpai_cae_arp.files
import
FileType
,
File
info
=
File
(
"config/server.yaml"
,
FileType
.
YAML
).
get_content
()
app
=
FastAPI
(
**
info
)
@
app
.
get
(
"/"
)
async
def
list_all_entrypoints
()
->
list
[
str
]:
"""
Get the list of available main routes.
"""
return
[
"restore"
,
"description"
,
"docs"
]
@
app
.
get
(
"/description"
)
async
def
get_server_info
()
->
Info
:
"""
Retrieve all the informations about the software running on the server.
"""
return
info
@
app
.
get
(
"/restore"
,
status_code
=
200
)
async
def
restore
(
response
:
Response
,
equalization_w
:
Annotated
[
str
,
Query
(
description
=
"Actual equalization of the audio tape applied during the recording."
,
example
=
"CCIR"
)],
equalization_r
:
Annotated
[
str
,
Query
(
description
=
"Actual equalization of the audio tape applied during the playback."
,
example
=
"NAB"
)],
speed_w
:
Annotated
[
str
,
Query
(
description
=
"Actual speed of the audio tape applied during the recording."
,
example
=
"7.5"
)],
speed_r
:
Annotated
[
str
,
Query
(
description
=
"Actual speed of the audio tape applied during the playback."
,
example
=
"15"
)],
files_name
:
Annotated
[
str
,
Query
(
description
=
"Name of the audio/video file to be analyzed without the extension."
,
example
=
"filename"
)],
working_path
:
Annotated
[
str
,
Query
(
description
=
"Path to the directory containing the preservation files."
,
examples
=
{
"Absolute path"
:
{
"value"
:
"/home/user/preservation"
},
"Relative path"
:
{
"value"
:
"preservation"
}
}
)]
=
None
)
->
dict
:
process
=
[
"python"
,
"src/tapeAudioRestoration.py"
,
"--files_name"
,
files_name
,
"--equalization-w"
,
equalization_w
,
"--equalization-r"
,
equalization_r
,
"--speed-w"
,
speed_w
,
"--speed-r"
,
speed_r
]
if
working_path
is
not
None
:
process
.
extend
([
"--working_path"
,
working_path
])
else
:
config
=
File
(
"config/args.yaml"
,
FileType
.
YAML
).
get_content
()
process
.
extend
([
"--working_path"
,
config
[
"WORKING_PATH"
]])
cprocess
=
subprocess
.
run
(
process
,
capture_output
=
True
)
if
cprocess
.
returncode
==
0
:
editing_list
=
File
(
"EditingList.json"
,
FileType
.
JSON
).
get_content
()
return
editing_list
else
:
response
.
status_code
=
status
.
HTTP_412_PRECONDITION_FAILED
return
{
"error"
:
{
"returncode"
:
cprocess
.
returncode
,
"stdout"
:
cprocess
.
stdout
.
decode
(
"utf-8"
),
"stderr"
:
cprocess
.
stderr
.
decode
(
"utf-8"
),
}}
src/tape_audio_restoration/__init__.py
0 → 100644
View file @
d4767d38
src/tape_audio_restoration/cli.py
0 → 100644
View file @
d4767d38
import
os
import
sys
from
argparse
import
ArgumentParser
,
RawTextHelpFormatter
from
typing
import
NoReturn
from
rich.console
import
Console
from
scipy.io
import
wavfile
from
mpai_cae_arp.files
import
File
,
FileType
from
mpai_cae_arp.io
import
Color
,
Style
,
pprint
from
mpai_cae_arp.audio
import
AudioWave
from
.lib
import
correction
,
get_correction_filter
,
save_file
,
check_input
def
get_args
()
->
tuple
[
str
,
str
,
str
,
float
,
str
,
float
]:
"""
Method to obtain arguments from environment variables or command line.
Default environment, ignored if a command line argument is passed.
Raises
------
ValueError
If no arguments are passed and at least one environment variable is not set.
Returns
-------
tuple[str, str, str, float, str, float]
tuple consisting of six variables:
* str specifying the working path;
* str specifying the name of the Preservation files, which is key element to retrieve necessary files;
* str specifying the equalization standard used when the tape was recorded;
* float specifying the speed used when the tape was recorded;
* str specifying the equalization standard used when the tape was read;
* float specifying the speed used when the tape was read.
"""
if
len
(
sys
.
argv
)
>
1
:
# Read from command line
parser
=
ArgumentParser
(
prog
=
"python3 tapeAudioRestoration.py"
,
formatter_class
=
RawTextHelpFormatter
,
description
=
"A tool that implements MPAI CAE-ARP Tape Audio Restoration Technical Specification.
\n
"
"By default, the configuration parameters are loaded from the environment,
\n
"
"but, alternately, you can pass command line arguments to replace them."
)
parser
.
add_argument
(
"-w"
,
"--working-path"
,
help
=
"Specify the Working Path, where all input files are stored"
,
required
=
True
)
parser
.
add_argument
(
"-f"
,
"--files-name"
,
help
=
"Specify the name of the Preservation files (without extension)"
,
required
=
True
)
parser
.
add_argument
(
"-ew"
,
"--equalization-w"
,
help
=
"Specify the name of the equalization standard used when the tape was recorded"
,
required
=
True
)
parser
.
add_argument
(
"-sw"
,
"--speed-w"
,
help
=
"Specify the speed used when the tape was recorded"
,
required
=
True
)
parser
.
add_argument
(
"-er"
,
"--equalization-r"
,
help
=
"Specify the name of the equalization standard used when the tape was read"
,
required
=
True
)
parser
.
add_argument
(
"-sr"
,
"--speed-r"
,
help
=
"Specify the speed used when the tape was read"
,
required
=
True
)
args
=
parser
.
parse_args
()
working_path
=
args
.
working_path
files_name
=
args
.
files_name
standard_w
=
args
.
equalization_w
speed_w
=
args
.
speed_w
standard_r
=
args
.
equalization_r
speed_r
=
args
.
speed_r
else
:
arg_names
=
[
'WORKING_PATH'
,
'FILES_NAME'
,
'STANDARD_W'
,
'SPEED_W'
,
'STANDARD_R'
,
'SPEED_R'
]
config
=
{
argument
:
os
.
getenv
(
argument
)
for
argument
in
arg_names
}
working_path
,
files_name
,
standard_w
,
speed_w
,
standard_r
,
speed_r
=
map
(
config
.
get
,
arg_names
)
if
any
(
value
is
None
for
value
in
config
.
values
()):
raise
ValueError
(
"Please, set the environment variables: WORKING_PATH, FILES_NAME, STANDARD_W, SPEED_W, STANDARD_R, SPEED_R."
)
return
working_path
,
files_name
,
standard_w
,
float
(
speed_w
),
standard_r
,
float
(
speed_r
)
def
exit_with_error
(
error_message
:
str
,
error
:
int
,
console
:
Console
)
->
NoReturn
:
console
.
print
(
f
"[red bold]Error:
{
error_message
}
"
)
quit
(
error
)
def
main
():
console
=
Console
()
console
.
print
(
"[bold]
\n
Welcome to ARP Tape Audio Restoration!"
)
console
.
print
(
f
"You are using Python version:
{
sys
.
version
}
"
)
try
:
working_path
,
files_name
,
standard_w
,
speed_w
,
standard_r
,
speed_r
=
get_args
()
paf_path
,
temp_path
,
standard_w
,
standard_r
=
check_input
(
working_path
,
files_name
,
standard_w
,
speed_w
,
standard_r
,
speed_r
)
# open the Preservation Audio file
with
console
.
status
(
"[bold]Opening Preservation Audio file..."
,
spinner
=
"dots"
):
sample_rate
,
preservation_audio_file
=
wavfile
.
read
(
paf_path
)
# get the correction filter
with
console
.
status
(
"[bold]Applying correction filter..."
,
spinner
=
"dots"
):
a
,
b
,
new_sample_rate
,
_
=
get_correction_filter
(
standard_w
,
speed_w
,
standard_r
,
speed_r
,
sample_rate
)
restored_audio_file
=
preservation_audio_file
# if needed, apply the correction filter to the Preservation Audio file
if
len
(
a
)
!=
0
:
restored_audio_file
=
correction
(
a
,
b
,
preservation_audio_file
,
round
(
new_sample_rate
))
with
console
.
status
(
"[bold]Saving Restoration Audio file..."
,
spinner
=
"dots"
):
save_file
(
restored_audio_file
,
round
(
new_sample_rate
),
temp_path
,
f
"
{
files_name
}
.wav"
)
except
ValueError
:
exit_with_error
(
"{}
\n
{}"
.
format
(
"Working directory or files name not specified!"
,
"Try -h/--help to know more about Tape Audio Restoration usage"
),
os
.
EX_USAGE
,
console
)
except
Exception
as
e
:
exit_with_error
(
str
(
e
),
os
.
EX_SOFTWARE
,
console
)
console
.
print
(
"[green] Success! :tada:"
)
quit
(
os
.
EX_OK
)
if
__name__
==
'__main__'
:
main
()
src/tape
A
udio
R
estoration.py
→
src/tape
_a
udio
_r
estoration
/lib
.py
View file @
d4767d38
#!./venv/bin/activate
"""
MPAI CAE-ARP Tape Audio Restoration.
...
...
@@ -14,109 +12,31 @@ import numpy as np
import
os
import
shutil
import
sys
from
argparse
import
ArgumentParser
,
RawTextHelpFormatter
from
statistics
import
mode
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
,
pprint
from
mpai_cae_arp.files
import
File
,
FileType
from
mpai_cae_arp.io
import
Color
,
Style
,
pprint
from
mpai_cae_arp.types.irregularity
import
IrregularityFile
,
Irregularity
,
IrregularityProperties
__author__
=
"Nadir Dalla Pozza"
__copyright__
=
"Copyright 2022, Audio Innova S.r.l."
__credits__
=
[
"Niccolò Pretto"
,
"Nadir Dalla Pozza"
,
"Sergio Canazza"
]
__license__
=
"GPL v3.0"
__version__
=
"1.0.1"
__maintainer__
=
"Nadir Dalla Pozza"
__email__
=
"nadir.dallapozza@unipd.it"
__status__
=
"Production"
def
get_arguments
()
->
tuple
[
str
,
str
,
str
,
float
,
str
,
float
]:
"""
Method to obtain arguments from config/args.yaml file or command line.
Default config/args.yaml, ignored if a command line argument is passed.
:return: tuple consisting of nine variables:
1) str specifying the working path;
2) str specifying the name of the Preservation files, which is key element to retrieve necessary files;
3) str specifying the equalization standard used when the tape was recorded;
4) float specifying the speed used when the tape was recorded;
5) str specifying the equalization standard used when the tape was read;
6) float specifying the speed used when the tape was read.
"""
def
verify_path
(
working_path
:
str
,
files_name
:
str
)
->
str
:
raise
NotImplementedError
if
len
(
sys
.
argv
)
>
1
:
# Read from command line
parser
=
ArgumentParser
(
prog
=
"python3 tapeAudioRestoration.py"
,
formatter_class
=
RawTextHelpFormatter
,
description
=
"A tool that implements MPAI CAE-ARP Tape Audio Restoration Technical Specification.
\n
"
"By default, the configuration parameters are loaded from ./config/args.yaml file,
\n
"
"but, alternately, you can pass command line arguments to replace them."
)
parser
.
add_argument
(
"-w"
,
"--working-path"
,
help
=
"Specify the Working Path, where all input files are stored"
,
required
=
True
)
parser
.
add_argument
(
"-f"
,
"--files-name"
,
help
=
"Specify the name of the Preservation files (without extension)"
,
required
=
True
)
parser
.
add_argument
(
"-ew"
,
"--equalization-w"
,
help
=
"Specify the name of the equalization standard used when the tape was recorded"
,
required
=
True
)
parser
.
add_argument
(
"-sw"
,
"--speed-w"
,
help
=
"Specify the speed used when the tape was recorded"
,
required
=
True
)
parser
.
add_argument
(
"-er"
,
"--equalization-r"
,
help
=
"Specify the name of the equalization standard used when the tape was read"
,
required
=
True
)
parser
.
add_argument
(
"-sr"
,
"--speed-r"
,
help
=
"Specify the speed used when the tape was read"
,
required
=
True
)
args
=
parser
.
parse_args
()
working_path
=
args
.
working_path
files_name
=
args
.
files_name
standard_w
=
args
.
equalization_w
speed_w
=
float
(
args
.
speed_w
)
standard_r
=
args
.
equalization_r
speed_r
=
float
(
args
.
speed_r
)
else
:
# Read configuration file
arg_names
=
[
'WORKING_PATH'
,
'FILES_NAME'
,
'STANDARD_W'
,
'SPEED_W'
,
'STANDARD_R'
,
'SPEED_R'
]
config
=
{}
try
:
config
=
File
(
'config/args.yaml'
,
FileType
.
YAML
).
get_content
()
for
argument
in
arg_names
:
if
argument
not
in
config
:
pprint
(
f
'
{
argument
}
key not found in config/args.yaml!'
,
color
=
Color
.
RED
)
quit
(
os
.
EX_CONFIG
)
except
FileNotFoundError
:
pprint
(
'config/args.yaml file not found!'
,
color
=
Color
.
RED
)
quit
(
os
.
EX_NOINPUT
)
# unpack config dictionary
working_path
,
files_name
,
standard_w
,
speed_w
,
standard_r
,
speed_r
=
map
(
config
.
get
,
arg_names
)
return
working_path
,
files_name
,
standard_w
,
speed_w
,
standard_r
,
speed_r
def
verify_equalization_and_speed
(
standard_w
:
str
,
speed_w
:
float
,
standard_r
:
str
,
speed_r
:
float
)
->
tuple
[
str
,
str
]:
"""
Method to verify that the equalization and speed parameters are correct.
"""
raise
NotImplementedError
def
check_input
(
working_path
:
str
,
files_name
:
str
,
standard_w
:
str
,
speed_w
:
float
,
standard_r
:
str
,
speed_r
:
float
)
->
tuple
[
str
,
str
,
str
,
str
]:
...
...
@@ -221,16 +141,29 @@ def check_input(working_path: str, files_name: str, standard_w: str, speed_w: fl
def
get_correction_filter
(
standard_w
:
str
,
speed_w
:
float
,
standard_r
:
str
,
speed_r
:
float
,
fs
:
int
)
->
tuple
[
list
,
list
,
float
,
int
]:
"""
Method to establish correct filter transfer function coefficients;
:param standard_w: str specifying the equalization standard used when the tape was recorded,
:param speed_w: float specifying the speed used when the tape was recorded,
:param standard_r: str specifying the equalization standard used when the tape was read,
:param speed_r: float specifying the speed used when the tape was read,
:param fs: float specifying the sampling frequency.
:return: tuple consisting of four variables:
1) array representing the filter numerator coefficients;
2) array representing the filter denominator coefficients;
3) float specifying the operating sampling frequency;
4) int informing about the case number.
Parameters
----------
standard_w : str
String specifying the equalization standard used when the tape was recorded.
speed_w : float
Float specifying the speed used when the tape was recorded.
standard_r : str
String specifying the equalization standard used when the tape was read.
speed_r : float
Float specifying the speed used when the tape was read.
fs : int
Integer specifying the sampling frequency.
Returns
-------
tuple
Tuple consisting of four variables:
* list of the filter numerator coefficients;
* list of the filter denominator coefficients;
* float specifying the operating sampling frequency;
* int informing about the case number.
"""
# CCIR time constants.
t2_30
=
17.5
*
10
**
(
-
6
)
# time constant CCIR_30
...
...
@@ -296,7 +229,7 @@ def get_correction_filter(standard_w: str, speed_w: float, standard_r: str, spee
# Case 31
if
speed_r
==
30
:
print
(
'Reference case: 31'
)
print
(
CC
.
GREEN
+
'Nothing to do!'
+
CC
.
EN
D
)
p
print
(
'Nothing to do!'
,
color
=
Color
.
GRE
EN
)
quit
(
os
.
EX_OK
)
# Case 15
elif
speed_r
==
15
:
...
...
@@ -658,11 +591,22 @@ def get_correction_filter(standard_w: str, speed_w: float, standard_r: str, spee
def
correction
(
a
:
array
,
b
:
array
,
paf
:
ndarray
,
fs
:
int
)
->
ndarray
:
"""
Apply a correction filter to a Preservation Audio File;
:param a: array of coefficients, specifying the numerator of filter transfer function,
:param b: array of coefficients, specifying in the denominator of filter transfer function,
:param paf: ndarray specifying the raw audio data of the Preservation Audio File,
:param fs: int specifying the operational sampling frequency.
:return: the corrected audio as a Restored Audio File.
Parameters
----------
a : array
array of coefficients, specifying the numerator of filter transfer function,
b : array
array of coefficients, specifying in the denominator of filter transfer function,
paf : ndarray
specifying the raw audio data of the Preservation Audio File,
fs : int
specifying the operational sampling frequency.
Returns
-------
ndarray
the corrected audio as a Restored Audio File.
"""
# Analog transfer function
...
...
@@ -707,11 +651,21 @@ def correction(a: array, b: array, paf: ndarray, fs: int) -> ndarray:
def
save_file
(
file
:
ndarray
,
fs
:
int
,
temp_path
:
str
,
name
:
str
):
"""
Save an audio file to the given path with name 1.wav;
:param file: ndarray specifying the raw audio data,
:param fs: int specifying the operational sampling frequency,
:param temp_path: str specifying the path where the file will be saved,
:param name: str specifying the file name.
:return: exit codes corresponding to the execution status.
Parameters
----------
file : ndarray
Array containing the raw audio data.
fs : int
Sampling frequency.
temp_path : str
Path where the file will be saved.
name : str
File name.
Returns
-------
exit codes corresponding to the execution status.
"""
raf_path
=
os
.
path
.
join
(
temp_path
,
'RestoredAudioFiles'
)
make_raf
=
False
...
...
@@ -737,55 +691,100 @@ def save_file(file: ndarray, fs: int, temp_path: str, name: str):
wavfile
.
write
(
os
.
path
.
join
(
raf_path
,
name
+
'.wav'
),
fs
,
file
)
def
main
():
"""
Main execution method.
:return: exit codes corresponding to the execution status.
def
read_params_from_irregularity_file
(
irregularity_file_path
:
str
)
->
tuple
[
str
,
float
,
str
,
float
]:
"""Get the parameters needed to apply the correction filter from the specified irregularity file.
Parameters
----------
irregularity_file_path : str
Path to the irregularity file.
Returns
-------
tuple[str, float, str, float]
Tuple containing the parameters needed to apply the correction filter.
It is assumed that the audio file considered contains only one recording session (so only one speed and equalisation).
Since it is only one recording session, the possible correction to be applied is only one, this fact allow us to
consider the mode of the equalisation and speed detected as the correct parameters.
If there are no irregularities properties in the irregularity file, the parameters default to:
- reading equalisation: NAB
- reading speed: 7.5
- writing equalisation: NAB
- writing speed: 7.5
"""
pprint
(
"
\n
Welcome to ARP Tape Audio Restoration!"
,
styles
=
[
Style
.
BOLD
])
print
(
"You are using Python version: "
+
sys
.
version
)
# Get the input from config/args.yaml or command line
working_path
,
files_name
,
standard_w
,
speed_w
,
standard_r
,
speed_r
=
get_arguments
()
# Check if input is correct
paf_path
,
temp_path
,
standard_w
,
standard_r
=
check_input
(
working_path
,
files_name
,
standard_w
,
speed_w
,
standard_r
,
speed_r
)
# Display input parameters
print
(
'
\n
Input parameters:'
)
print
(
' WORKING_PATH: '
+
working_path
)
print
(
' FILES_NAME: '
+
files_name
)
print
(
' STANDARD_W: '
+
standard_w
)
print
(
' SPEED_W: '
+
str
(
speed_w
)
+
' ips'
)
print
(
' STANDARD_R: '
+
standard_r
)
print
(
' SPEED_R: '
+
str
(
speed_r
)
+
' ips'
)
# Preservation Audio File check
print
(
"Opening '%s'..."
%
paf_path
)
fs
,
paf
=
wavfile
.
read
(
paf_path
)
print
(
'Preservation Audio File opened!'
)
print
(
' FS: '
+
str
(
fs
)
+
' Hz
\n
'
)
# Decision stage
a
,
b
,
fs
,
case
=
get_correction_filter
(
standard_w
,
speed_w
,
standard_r
,
speed_r
,
fs
)
# Casting FS to int because wavfile.write() is stupid
fs
=
round
(
fs
)
print
(
'Reference case: '
+
str
(
case
))
print
(
'Operational FS: '
+
str
(
fs
)
+
' Hz.'
)
# Correction phase
if
len
(
a
)
!=
0
:
# Not all cases present a correction filter!
raf
=
correction
(
a
,
b
,
paf
,
fs
)
save_file
(
raf
,
fs
,
temp_path
,
'1'
)
else
:
# Just save Restored Audio File, but with modified fs
save_file
(
paf
,
fs
,
temp_path
,
'1'
)
# End
pprint
(
"Success!
\n
"
,
color
=
Color
.
GREEN
,
styles
=
[
Style
.
BOLD
])
if
__name__
==
'__main__'
:
main
()
json_content
=
File
(
irregularity_file_path
,
FileType
.
JSON
).
get_content
()
irregularity_file
=
IrregularityFile
.
from_json
(
json_content
)
write_speeds
=
[]
read_speeds
=
[]
write_eq
=
[]
read_eq
=
[]
for
irr
in
irregularity_file
.
irregularities
:
if
irr
.
irregularity_properties
is
not
None
:
read_eq
.
append
(
irr
.
irregularity_properties
.
reading_equalisation
)
read_speeds
.
append
(
irr
.
irregularity_properties
.
reading_speed
)
write_eq
.
append
(
irr
.
irregularity_properties
.
writing_equalisation
)
write_speeds
.
append
(
irr
.
irregularity_properties
.
writing_speed
)
else
:
read_eq
.
append
(
None
)
read_speeds
.
append
(
None
)
write_eq
.
append
(
None
)
write_speeds
.
append
(
None
)
result_ws
,
result_rs
,
result_we
,
result_re
=
mode
(
write_speeds
),
mode
(
read_speeds
),
mode
(
write_eq
),
mode
(
read_eq
)
if
all
(
x
is
None
for
x
in
[
result_rs
,
result_ws
])
or
len
(
write_speeds
)
==
0
:
result_ws
,
result_rs
=
7.5
,
7.5
if
all
(
x
is
None
for
x
in
[
result_we
,
result_re
])
or
len
(
write_eq
)
==
0
:
result_we
,
result_re
=
'NAB'
,
'NAB'
return
result_we
,
result_ws
,
result_re
,
result_rs
# def main():
# """
# Main execution method.
# :return: exit codes corresponding to the execution status.
# """
# pprint("\nWelcome to ARP Tape Audio Restoration!", styles=[Style.BOLD])
# print("You are using Python version: " + sys.version)
# # Get the input from config/args.yaml or command line
# working_path, files_name, standard_w, speed_w, standard_r, speed_r = get_args()
# # Check if input is correct
# paf_path, temp_path, standard_w, standard_r = check_input(working_path, files_name, standard_w, speed_w, standard_r, speed_r)
# # Display input parameters
# print('\nInput parameters:')
# print(' WORKING_PATH: ' + working_path)
# print(' FILES_NAME: ' + files_name)
# print(' STANDARD_W: ' + standard_w)
# print(' SPEED_W: ' + str(speed_w) + ' ips')
# print(' STANDARD_R: ' + standard_r)
# print(' SPEED_R: ' + str(speed_r) + ' ips')
# # Preservation Audio File check
# print("Opening '%s'..." % paf_path)
# fs, paf = wavfile.read(paf_path)
# print('Preservation Audio File opened!')
# print(' FS: ' + str(fs) + ' Hz\n')
# # Decision stage
# a, b, fs, case = get_correction_filter(standard_w, speed_w, standard_r, speed_r, fs)
# # Casting FS to int because wavfile.write() is stupid
# fs = round(fs)
# print('Reference case: ' + str(case))
# print('Operational FS: ' + str(fs) + ' Hz.')
# # Correction phase
# if len(a) != 0:
# # Not all cases present a correction filter!
# raf = correction(a, b, paf, fs)
# save_file(raf, fs, temp_path, '1')
# else:
# # Just save Restored Audio File, but with modified fs
# save_file(paf, fs, temp_path, '1')
# # End
# pprint("Success!\n", color=Color.GREEN, styles=[Style.BOLD])
src/tape_audio_restoration/server.py
0 → 100644
View file @
d4767d38
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment