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