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
ARP Library
Commits
bd641223
Commit
bd641223
authored
Apr 04, 2023
by
Matteo
Browse files
add io module
parent
888ae46e
Changes
4
Hide whitespace changes
Inline
Side-by-side
mpai_cae_arp/__init__.py
View file @
bd641223
__author__
=
"Matteo Spanio"
__copyright__
=
"Copyright 2023, Audio Innova S.r.l."
__credits__
=
[
"Niccolò Pretto"
,
"Nadir Dalla Pozza"
,
"Sergio Canazza"
]
__license__
=
"GPL v3.0"
__maintainer__
=
"Matteo Spanio"
__email__
=
"dev2@audioinnova.com"
__status__
=
"Development"
mpai_cae_arp/io.py
0 → 100644
View file @
bd641223
from
enum
import
Enum
END
=
'
\033
[0m'
class
Style
(
Enum
):
"""
Styles for console output
"""
BOLD
=
'
\033
[1m'
UNDERLINE
=
'
\033
[4m'
class
Color
(
Enum
):
"""
Colors for console output
"""
PURPLE
=
'
\033
[95m'
CYAN
=
'
\033
[96m'
DARK_CYAN
=
'
\033
[36m'
BLUE
=
'
\033
[94m'
GREEN
=
'
\033
[92m'
YELLOW
=
'
\033
[93m'
RED
=
'
\033
[91m'
def
prettify
(
text
:
str
,
color
:
Color
=
None
,
styles
:
list
[
Style
]
=
None
)
->
str
:
"""
Formats a string with some styles
Parameters
----------
text : str
string to format
color : Color, optional
color to use
styles : list[Style], optional
styles to use
Returns
-------
str
formatted string
"""
prepend
=
''
if
color
:
prepend
+=
color
.
value
if
styles
:
for
style
in
styles
:
prepend
+=
style
.
value
return
prepend
+
text
+
END
mpai_cae_arp/types/irregularity.py
View file @
bd641223
import
uuid
import
uuid
from
dataclasses
import
dataclass
from
enum
import
Enum
from
enum
import
Enum
from
pydantic
import
BaseModel
,
Field
from
typing
import
Annotated
from
mpai_cae_arp.audio.standards
import
EqualizationStandard
,
SpeedStandard
from
mpai_cae_arp.audio.standards
import
EqualizationStandard
,
SpeedStandard
...
@@ -28,22 +29,12 @@ class Source(Enum):
...
@@ -28,22 +29,12 @@ class Source(Enum):
BOTH
=
"b"
BOTH
=
"b"
@
dataclass
class
IrregularityProperties
(
BaseModel
):
class
IrregularityProperties
:
reading_speed
:
SpeedStandard
reading_speed
:
SpeedStandard
reading_equalisation
:
EqualizationStandard
reading_equalisation
:
EqualizationStandard
writing_speed
:
SpeedStandard
writing_speed
:
SpeedStandard
writing_equalisation
:
EqualizationStandard
writing_equalisation
:
EqualizationStandard
@
staticmethod
def
from_classification
(
classification_result
:
ClassificationResult
):
return
IrregularityProperties
(
reading_speed
=
classification_result
.
reading_speed
,
reading_equalisation
=
classification_result
.
reading_equalization
,
writing_speed
=
classification_result
.
writing_speed
,
writing_equalisation
=
classification_result
.
writing_equalization
,
)
@
staticmethod
@
staticmethod
def
from_json
(
json_property
:
dict
):
def
from_json
(
json_property
:
dict
):
return
IrregularityProperties
(
return
IrregularityProperties
(
...
@@ -63,8 +54,7 @@ class IrregularityProperties:
...
@@ -63,8 +54,7 @@ class IrregularityProperties:
}
}
@
dataclass
class
Irregularity
(
BaseModel
):
class
Irregularity
:
irregularity_ID
:
uuid
.
UUID
irregularity_ID
:
uuid
.
UUID
source
:
Source
source
:
Source
time_label
:
str
time_label
:
str
...
@@ -127,10 +117,33 @@ class Irregularity:
...
@@ -127,10 +117,33 @@ class Irregularity:
return
dictionary
return
dictionary
class
IrregularityFile
:
class
IrregularityFile
(
BaseModel
)
:
# TODO: the offset calculation is not implemented yet, so it is set to None
# TODO: the offset calculation is not implemented yet, so it is set to None
irregularities
:
list
[
Irregularity
]
irregularities
:
list
[
Irregularity
]
offset
:
int
|
None
offset
:
Annotated
[
int
,
Field
(
gt
=
0
)]
|
None
class
Config
:
schema_extra
=
{
"example"
:
{
"offset"
:
0
,
"irregularities"
:
[
{
"irregularity_ID"
:
"a0a0a0a0-a0a0-a0a0-a0a0-a0a0a0a0a0a0"
,
"source"
:
"a"
,
"time_label"
:
"00:00:00:00"
,
"irregularity_type"
:
"b"
,
"irregularity_properties"
:
{
"reading_speed"
:
"n"
,
"reading_equalisation"
:
"n"
,
"writing_speed"
:
"n"
,
"writing_equalisation"
:
"n"
},
"audio_block_URI"
:
"https://example.com/audio.wav"
,
}
]
}
}
def
__init__
(
self
,
def
__init__
(
self
,
irregularities
:
list
[
Irregularity
]
=
[],
irregularities
:
list
[
Irregularity
]
=
[],
...
...
pyproject.toml
View file @
bd641223
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
name = "mpai-cae-arp"
name = "mpai-cae-arp"
version = "0.1.0"
version = "0.1.0"
description = "The MPAI CAE-ARP software API"
description = "The MPAI CAE-ARP software API"
authors
=
[
"Matteo Spanio <
matteo.spanio97@gmail
.com>"
]
authors = ["Matteo Spanio <
dev2@audioinnova
.com>"]
readme = "README.md"
readme = "README.md"
packages = [{include = "mpai_cae_arp"}]
packages = [{include = "mpai_cae_arp"}]
...
...
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