Commit 7d47c064 authored by Matteo's avatar Matteo
Browse files

update

parent 2273871b
test/ test/
.editorconfig .editorconfig
.gitignore .gitignore
\ No newline at end of file .env
\ No newline at end of file
...@@ -4,6 +4,8 @@ WORKDIR /app ...@@ -4,6 +4,8 @@ WORKDIR /app
COPY . ./ COPY . ./
RUN apt install ffmpeg -y
RUN poetry install --no-cache --only main RUN poetry install --no-cache --only main
VOLUME [ "/data" ] VOLUME [ "/data" ]
......
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
[tool.poetry] [tool.poetry]
name = "audio-analyzer" name = "audio-analyzer"
version = "0.1.0" version = "1.0.0"
description = "MPAI CAE-ARP Audio Analyser" description = "MPAI CAE-ARP Audio Analyser"
authors = ["Matteo Spanio <dev2@audioinnova.com>"] authors = ["Matteo Spanio <dev2@audioinnova.com>"]
license = "GPLv3" license = "GPLv3"
......
...@@ -44,7 +44,7 @@ def main() -> None: ...@@ -44,7 +44,7 @@ def main() -> None:
"Try -h/--help to know more about Audio Analyser usage"), console) "Try -h/--help to know more about Audio Analyser usage"), console)
try: try:
os.makedirs(os.path.join(working_directory, "temp", files_name)) os.makedirs(os.path.join(working_directory, "temp", files_name), exist_ok=True)
except: except:
exit_with_error("Unable to create temporary directory, output path already exists", console) exit_with_error("Unable to create temporary directory, output path already exists", console)
...@@ -69,26 +69,15 @@ def main() -> None: ...@@ -69,26 +69,15 @@ def main() -> None:
with console.status("[purple]Creating irregularity file 1", spinner="dots"): with console.status("[purple]Creating irregularity file 1", spinner="dots"):
irreg1 = sf.create_irreg_file(audio_src, video_src) irreg1 = sf.create_irreg_file(audio_src, video_src)
console.log(f"Found {len(irreg1.irregularities)} irregularities from Audio source") console.log(f"Found {len(irreg1.irregularities)} irregularities from Audio source")
File(f"{working_directory}/temp/{files_name}/IrregularityFile1.json", FileType.JSON).write_content(irreg1.to_json()) File(f"{working_directory}/temp/{files_name}/AudioAnalyser_IrregularityFileOutput1.json", FileType.JSON).write_content(irreg1.to_json())
console.log("[geen]Irregularity file 1 created") console.log("[geen]Irregularity file 1 created")
# create irregularity file 2 # create irregularity file 2
with console.status("[purple]Creating irregularity file 2", spinner="dots"): with console.status("[purple]Creating irregularity file 2", spinner="dots"):
video_irreg_1 = { try:
"Irregularities": [ video_irreg_1 = File(f"{working_directory}/temp/{files_name}/VideoAnalyser_IrregularityFileOutput1.json", FileType.JSON).get_content()
{ except:
"TimeLabel": "00:03:00.000", exit_with_error("Video irregularity file 1 not found", console)
"Source": "v",
"IrregularityID": "09a0b0c0-d0e0-f000-0000-000000000000"
},
{
"TimeLabel": "00:03:01.000",
"Source": "v",
"IrregularityID": "09a0b0c0-d0e0-f000-0000-000000000001"
}
],
"Offset": 170
}
console.log("Video irregularity file 1 found") console.log("Video irregularity file 1 found")
irreg2 = sf.merge_irreg_files(irreg1, IrregularityFile.from_json(video_irreg_1)) irreg2 = sf.merge_irreg_files(irreg1, IrregularityFile.from_json(video_irreg_1))
console.log("[geen]Irregularity file 2 created") console.log("[geen]Irregularity file 2 created")
...@@ -110,7 +99,7 @@ def main() -> None: ...@@ -110,7 +99,7 @@ def main() -> None:
irreg.irregularity_type = classification_result.get_irregularity_type() irreg.irregularity_type = classification_result.get_irregularity_type()
irreg.irregularity_properties = classification_result if classification_result.get_irregularity_type() is not None else None irreg.irregularity_properties = classification_result if classification_result.get_irregularity_type() is not None else None
File(f"{working_directory}/temp/{files_name}/IrregularityFile2.json", FileType.JSON).write_content(irreg2.to_json()) File(f"{working_directory}/temp/{files_name}/AudioAnalyser_IrregularityFileOutput2.json", FileType.JSON).write_content(irreg2.to_json())
console.print("[green bold]Success! :tada:") console.print("[green bold]Success! :tada:")
quit(os.EX_OK) quit(os.EX_OK)
......
...@@ -26,7 +26,7 @@ def run(console: Console): ...@@ -26,7 +26,7 @@ def run(console: Console):
request = arp_pb2.JobRequest( request = arp_pb2.JobRequest(
working_dir="../data", working_dir="../data",
files_name="BERIO100", files_name="BERIO100",
index=1, index=2,
) )
with console.status("[bold]Computing...", spinner="bouncingBall"): with console.status("[bold]Computing...", spinner="bouncingBall"):
for result in audio_analyser.work(request): for result in audio_analyser.work(request):
......
...@@ -19,7 +19,7 @@ from mpai_cae_arp.network.arp_pb2 import ( ...@@ -19,7 +19,7 @@ from mpai_cae_arp.network.arp_pb2 import (
import segment_finder as sf import segment_finder as sf
import classifier as cl import classifier as cl
info = File('config/server.yaml', FileType.YAML).get_content() info = File('config.yml', FileType.YAML).get_content()
def try_or_error_response( def try_or_error_response(
...@@ -86,9 +86,9 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer): ...@@ -86,9 +86,9 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer):
video_src = os.path.join(working_dir, "PreservationAudioVisualFile", f"{files_name}.mov") video_src = os.path.join(working_dir, "PreservationAudioVisualFile", f"{files_name}.mov")
temp_dir = os.path.join(working_dir, "temp", files_name) temp_dir = os.path.join(working_dir, "temp", files_name)
audio_irreg_1 = os.path.join(temp_dir, "AudioAnalyser_IrregularityFileOutput_1.json") audio_irreg_1 = os.path.join(temp_dir, "AudioAnalyser_IrregularityFileOutput1.json")
audio_irreg_2 = os.path.join(temp_dir, "AudioAnalyser_IrregularityFileOutput_2.json") audio_irreg_2 = os.path.join(temp_dir, "AudioAnalyser_IrregularityFileOutput2.json")
video_irreg_1 = os.path.join(temp_dir, "VideoAnalyser_IrregularityFileOutput_1.json") video_irreg_1 = os.path.join(temp_dir, "VideoAnalyser_IrregularityFileOutput1.json")
if index == 1: if index == 1:
...@@ -121,10 +121,13 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer): ...@@ -121,10 +121,13 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer):
if index == 2: if index == 2:
audio_irregularity_1 = File(audio_irreg_1, FileType.JSON).get_content()
video_irregularity_1 = File(video_irreg_1, FileType.JSON).get_content()
response, irreg2 = try_or_error_response( response, irreg2 = try_or_error_response(
context, context,
func=sf.merge_irreg_files, func=sf.merge_irreg_files,
args=(irreg1, IrregularityFile.from_json(video_irreg_1)), args=(IrregularityFile.from_json(audio_irregularity_1), IrregularityFile.from_json(video_irregularity_1)),
on_success_message="Irregularity files merged successfully", on_success_message="Irregularity files merged successfully",
on_error_message="Failed to merge irregularity files", on_error_message="Failed to merge irregularity files",
) )
...@@ -142,7 +145,7 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer): ...@@ -142,7 +145,7 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer):
response, irregularities_features = try_or_error_response( response, irregularities_features = try_or_error_response(
context, context,
func=cl.extract_features, func=cl.extract_features,
args=irreg2.irregularities, args=[irreg2.irregularities],
on_success_message="Audio irregularities features extracted", on_success_message="Audio irregularities features extracted",
on_error_message="Failed to extract audio irregularities features", on_error_message="Failed to extract audio irregularities features",
) )
...@@ -151,7 +154,7 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer): ...@@ -151,7 +154,7 @@ class AudioAnalyserServicer(arp_pb2_grpc.AIMServicer):
response, classification_results = try_or_error_response( response, classification_results = try_or_error_response(
context, context,
func=cl.classify, func=cl.classify,
args=irregularities_features, args=[irregularities_features],
on_success_message="Audio irregularities classified", on_success_message="Audio irregularities classified",
on_error_message="Failed to classify audio irregularities", on_error_message="Failed to classify audio irregularities",
) )
......
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