Commit 94b229e9 authored by Matteo's avatar Matteo
Browse files

update

parent 9c46f0cc
Pipeline #16 failed with stages
in 0 seconds
test/
.editorconfig
.gitignore
\ No newline at end of file
FROM matteospanio/poetry:latest AS poetry
WORKDIR /app
COPY . ./
RUN poetry install --no-cache --only main
VOLUME [ "/data" ]
CMD ["poetry", "run", "uvicorn", "src.server:app", "--host", "0.0.0.0", "--port", "80", "--log-config", "config/logger.yaml"]
\ No newline at end of file
......@@ -14,7 +14,7 @@ endif
.PHONY: help clean docs
clean: clean-build clean-pyc clean-test
clean: clean-build clean-pyc clean-ruff clean-test
clean-build:
rm -fr build/
......@@ -29,6 +29,9 @@ clean-pyc:
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-ruff:
rm -fr .ruff_cache/
clean-test:
rm -fr .tox/
rm -f .coverage
......
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/packager/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
title: Audio Analyser
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/)
Implements the Technical Specification of [MPAI CAE-ARP](https://mpai.community/standards/mpai-cae/about-mpai-cae/#Figure2) *Audio Analyser* AIM, providing:
version: 1.0.0
contact:
name: Matteo Spanio
email: dev2@audioinnova.com
license_info:
name: GNU General Public License v3.0
url: https://www.gnu.org/licenses/gpl-3.0.en.html
\ No newline at end of file
......@@ -729,14 +729,14 @@ files = [
[[package]]
name = "mpai-cae-arp"
version = "0.2.0"
version = "0.2.1"
description = "The MPAI CAE-ARP software API"
category = "main"
optional = false
python-versions = ">=3.10,<4.0"
files = [
{file = "mpai_cae_arp-0.2.0-py3-none-any.whl", hash = "sha256:b35410f0cc127f8a60eedb45e8878e41adfdf7b31ffb8b38216ce263cafb424b"},
{file = "mpai_cae_arp-0.2.0.tar.gz", hash = "sha256:e9833f22cffe2dfe77714e0a051c24dd6c9b6cc6ff1036956669ac319602dc0b"},
{file = "mpai_cae_arp-0.2.1-py3-none-any.whl", hash = "sha256:20bea510346e620d202acf340d055d5906b332738fbf4eed8ce637b52c0b3b85"},
{file = "mpai_cae_arp-0.2.1.tar.gz", hash = "sha256:9a36a913ca91bb5ecedd44d3edb9230e1af46b8eaed4650ba957b6144bd3eba9"},
]
[package.dependencies]
......@@ -1936,4 +1936,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "81df59f98e6ae427be2a855aeb2b191e867da2f83dd5364d01c51c62fde86cb9"
content-hash = "0c3763c54b9876a9c5ca29c18660439e1f2b09f42cd2cb009114d52a89d94e9f"
......@@ -5,11 +5,10 @@ description = "MPAI CAE-ARP Audio Analyser"
authors = ["Matteo Spanio <dev2@audioinnova.com>"]
license = "GPLv3"
readme = "README.md"
packages = [{include = "audio_analyzer"}]
[tool.poetry.dependencies]
python = "^3.10"
mpai-cae-arp = "^0.2.0"
mpai-cae-arp = "^0.2.1"
numpy = "1.23.3"
......
import segment_finder as sf
if __name__ == "__main__":
print(sf.create_irreg_file("test.wav", "test.mp4"))
\ No newline at end of file
from uuid import uuid4
import numpy as np
from mpai_cae_arp.types.irregularity import Irregularity, Source
from mpai_cae_arp.audio import AudioWave, Noise
from mpai_cae_arp.types.irregularity import Irregularity, IrregularityFile, Source
from mpai_cae_arp.time import frames_to_seconds
......@@ -26,20 +26,33 @@ def calculate_offset(audio: AudioWave, video: AudioWave) -> float:
lags = np.arange(-len(audio.array) + 1, len(video.array))
lag_idx = np.argmax(np.abs(corr))
return lags[lag_idx] / audio.sample_rate
return lags[lag_idx] / audio.samplerate
def foo():
input = AudioWave.from_file("input.wav")
def foo(audio_src) -> list[Irregularity]:
input = AudioWave.from_file(audio_src)
input_channels: list[AudioWave] = []
for channel in input.channels:
input_channels.append(input.get_channel(channel))
irreg_list: list[Irregularity] = []
for audio in input_channels:
for chunk in audio.get_silence_slices([Noise("A", -50, -63), Noise("B", -63, -69), Noise("C", -69, -72)], 500):
Irregularity(
uuid=uuid4(),
source=Source.AUDIO,
time_label=frames_to_seconds
)
for _, noise_list in audio.get_silence_slices([
Noise("A", -50, -63),
Noise("B", -63, -69),
Noise("C", -69, -72)],
length=500).items():
for start, _ in noise_list:
irreg_list.append(
Irregularity(
uuid=uuid4(),
source=Source.AUDIO,
time_label=frames_to_seconds(start, audio.samplerate)
)
)
return irreg_list
def create_irreg_file(audio_src, video_src) -> IrregularityFile:
offset = calculate_offset(AudioWave.from_file(audio_src), video_src)
return IrregularityFile(foo(audio_src), offset=offset)
from fastapi import FastAPI
from mpai_cae_arp.files import File, FileType
from mpai_cae_arp.types.irregularity import IrregularityFile
from mpai_cae_arp.types.schema import Info
info = File('config/server.yaml', FileType.YAML).get_content()
app = FastAPI(**info)
@app.get('/')
async def get_endpoints_list() -> list[str]:
"""Get list of all endpoints."""
return [route.path for route in app.routes]
@app.get('/description')
async def get_description() -> Info:
"""Get description of the server."""
return info
@app.get('/irregularityFile/{id}')
async def get_irregularity_file(id: int) -> IrregularityFile:
"""Get irregularity file by id."""
return IrregularityFile(irregularities=[], offset=150)
\ No newline at end of file
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