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
6b43a93e
Commit
6b43a93e
authored
Apr 17, 2023
by
Matteo
Browse files
update
parent
7d47c064
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/client.py
View file @
6b43a93e
...
@@ -7,40 +7,69 @@ from mpai_cae_arp.network import arp_pb2
...
@@ -7,40 +7,69 @@ from mpai_cae_arp.network import arp_pb2
from
mpai_cae_arp.network
import
arp_pb2_grpc
from
mpai_cae_arp.network
import
arp_pb2_grpc
channels
=
{
channels
=
{
"AudioAnalyser"
:
grpc
.
insecure_channel
(
"[::]:50051
/audio-analyser
"
),
"AudioAnalyser"
:
grpc
.
insecure_channel
(
"[::]:50051"
),
"VideoAnalyser"
:
grpc
.
insecure_channel
(
"[::]:5005
1/video-analyser
"
),
"VideoAnalyser"
:
grpc
.
insecure_channel
(
"[::]:5005
2
"
),
"TapeIrregularityClassifier"
:
grpc
.
insecure_channel
(
"[::]:50051/tape-irregularity-classifier"
),
"TapeIrregularityClassifier"
:
grpc
.
insecure_channel
(
"[::]:50051/tape-irregularity-classifier"
),
"TapeAudioRestoration"
:
grpc
.
insecure_channel
(
"[::]:50051/tape-audio-restoration"
),
"TapeAudioRestoration"
:
grpc
.
insecure_channel
(
"[::]:50051/tape-audio-restoration"
),
"Packager"
:
grpc
.
insecure_channel
(
"[::]:50051/packager"
),
"Packager"
:
grpc
.
insecure_channel
(
"[::]:50051/packager"
),
}
}
def
run
(
console
:
Console
):
def
run
(
console
:
Console
):
with
grpc
.
insecure_channel
(
"[::]:50051"
)
as
channel
:
audio_analyser
=
arp_pb2_grpc
.
AIMStub
(
channel
)
request
=
arp_pb2
.
InfoRequest
()
audio_analyser
=
arp_pb2_grpc
.
AIMStub
(
channels
[
"AudioAnalyser"
])
response
=
audio_analyser
.
getInfo
(
request
)
video_analyser
=
arp_pb2_grpc
.
AIMStub
(
channels
[
"VideoAnalyser"
])
request
=
arp_pb2
.
InfoRequest
()
for
analyser
in
[
audio_analyser
,
video_analyser
]:
response
=
analyser
.
getInfo
(
request
)
console
.
print
(
"[bold]{}[/], v{}"
.
format
(
response
.
title
,
response
.
version
))
console
.
print
(
"[bold]{}[/], v{}"
.
format
(
response
.
title
,
response
.
version
))
console
.
print
(
Markdown
(
response
.
description
))
console
.
print
(
Markdown
(
response
.
description
))
request
=
arp_pb2
.
JobRequest
(
request
=
arp_pb2
.
JobRequest
(
working_dir
=
"../data"
,
working_dir
=
"../data"
,
files_name
=
"BERIO100"
,
files_name
=
"BERIO100"
,
index
=
2
,
index
=
1
,
)
)
with
console
.
status
(
"[bold]Computing..."
,
spinner
=
"bouncingBall"
):
for
result
in
audio_analyser
.
work
(
request
):
with
console
.
status
(
"[bold]Computing AudioAnalyser IrregularityFile 1..."
,
spinner
=
"bouncingBall"
):
if
result
.
status
==
"error"
:
for
result
in
audio_analyser
.
work
(
request
):
console
.
print
(
"[bold red]Error![/] :boom:"
)
if
result
.
status
==
"error"
:
console
.
print
(
f
"[italic red]
{
result
.
message
}
"
)
console
.
print
(
"[bold red]Error![/] :boom:"
)
for
channel
in
channels
.
values
():
console
.
print
(
f
"[italic red]
{
result
.
message
}
"
)
channel
.
close
()
for
channel
in
channels
.
values
():
exit
(
os
.
EX_SOFTWARE
)
channel
.
close
()
console
.
print
(
result
.
message
)
exit
(
os
.
EX_SOFTWARE
)
console
.
print
(
result
.
message
)
request
.
files_name
=
"BERIO100.mov"
with
console
.
status
(
"[bold]Computing VideoAnalyser IrregularityFiles..."
,
spinner
=
"bouncingBall"
):
for
result
in
video_analyser
.
work
(
request
):
if
result
.
status
==
"error"
:
console
.
print
(
"[bold red]Error![/] :boom:"
)
console
.
print
(
f
"[italic red]
{
result
.
message
}
"
)
for
channel
in
channels
.
values
():
channel
.
close
()
exit
(
os
.
EX_SOFTWARE
)
console
.
print
(
result
.
message
)
request
.
index
=
2
request
.
files_name
=
"BERIO100"
with
console
.
status
(
"[bold]Computing AudioAnalyser IrregularityFile 2..."
,
spinner
=
"bouncingBall"
):
for
result
in
audio_analyser
.
work
(
request
):
if
result
.
status
==
"error"
:
console
.
print
(
"[bold red]Error![/] :boom:"
)
console
.
print
(
f
"[italic red]
{
result
.
message
}
"
)
for
channel
in
channels
.
values
():
channel
.
close
()
exit
(
os
.
EX_SOFTWARE
)
console
.
print
(
result
.
message
)
channels
[
"AudioAnalyser"
].
close
()
channels
[
"VideoAnalyser"
].
close
()
console
.
print
(
"[bold green]Success![/] :tada:"
)
console
.
print
(
"[bold green]Success![/] :tada:"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
console
=
Console
()
console
=
Console
()
run
(
console
)
run
(
console
)
\ No newline at end of file
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