Audio

class oceanai.modules.lab.audio.AudioMessages(lang: str = 'ru', color_simple: str = '#666', color_info: str = '#1776D2', color_err: str = '#FF0000', color_true: str = '#008001', bold_text: bool = True, text_runtime: str = '', num_to_df_display: int = 30)[source]

Bases: Download

Class for messages

Parameters:
class oceanai.modules.lab.audio.Audio(lang: str = 'ru', color_simple: str = '#666', color_info: str = '#1776D2', color_err: str = '#FF0000', color_true: str = '#008001', bold_text: bool = True, text_runtime: str = '', num_to_df_display: int = 30)[source]

Bases: AudioMessages

Audio processing class

Parameters:
__concat_pred(pred_hc: ndarray, pred_melspectrogram: ndarray, out: bool = True) List[ndarray | None]

Concatenation of scores by hand-crafted and deep features

Note

private method

Parameters:
  • pred_hc (np.ndarray) – Scores based on had-crafted features

  • pred_melspectrogram (np.ndarray) – Scores based on deep features

  • out (bool) – Display

Returns:

Concatenated scores by hand-crafted and deep features

Return type:

List[Optional[np.ndarray]]

Examples

True – 1 –

In [1]:
 1import numpy as np
 2from oceanai.modules.lab.audio import Audio
 3
 4audio = Audio(lang = 'en')
 5
 6arr_hc = np.array([
 7    [0.64113516, 0.6217892, 0.54451424, 0.6144415, 0.59334993],
 8    [0.6652424, 0.63606125, 0.572305, 0.63169795, 0.612515]
 9])
10
11arr_melspectrogram = np.array([
12    [0.56030345, 0.7488746, 0.44648764, 0.59893465, 0.5701077],
13    [0.5900006, 0.7652722, 0.4795154, 0.6409055, 0.6088242]
14])
15
16audio._Audio__concat_pred(
17    pred_hc = arr_hc,
18    pred_melspectrogram = arr_melspectrogram,
19    out = True
20)
[1]:
 1[
 2    array([
 3            0.64113516, 0.6652424, 0.65318878, 0.65318878, 0.65318878,
 4            0.65318878, 0.65318878, 0.65318878, 0.65318878, 0.65318878,
 5            0.65318878, 0.65318878, 0.65318878, 0.65318878, 0.65318878,
 6            0.65318878, 0.56030345, 0.5900006, 0.57515202, 0.57515202,
 7            0.57515202, 0.57515202, 0.57515202, 0.57515202, 0.57515202,
 8            0.57515202, 0.57515202, 0.57515202, 0.57515202, 0.57515202,
 9            0.57515202, 0.57515202
10    ]),
11    array([
12            0.6217892, 0.63606125, 0.62892523, 0.62892523, 0.62892523,
13            0.62892523, 0.62892523, 0.62892523, 0.62892523, 0.62892523,
14            0.62892523, 0.62892523, 0.62892523, 0.62892523, 0.62892523,
15            0.62892523, 0.7488746, 0.7652722, 0.7570734, 0.7570734,
16            0.7570734, 0.7570734, 0.7570734, 0.7570734, 0.7570734,
17            0.7570734, 0.7570734, 0.7570734, 0.7570734, 0.7570734,
18            0.7570734, 0.7570734
19    ]),
20    array([
21            0.54451424, 0.572305, 0.55840962, 0.55840962, 0.55840962,
22            0.55840962, 0.55840962, 0.55840962, 0.55840962, 0.55840962,
23            0.55840962, 0.55840962, 0.55840962, 0.55840962, 0.55840962,
24            0.55840962, 0.44648764, 0.4795154, 0.46300152, 0.46300152,
25            0.46300152, 0.46300152, 0.46300152, 0.46300152, 0.46300152,
26            0.46300152, 0.46300152, 0.46300152, 0.46300152, 0.46300152,
27            0.46300152, 0.46300152
28    ]),
29    array([
30            0.6144415, 0.63169795, 0.62306972, 0.62306972, 0.62306972,
31            0.62306972, 0.62306972, 0.62306972, 0.62306972, 0.62306972,
32            0.62306972, 0.62306972, 0.62306972, 0.62306972, 0.62306972,
33            0.62306972, 0.59893465, 0.6409055, 0.61992008, 0.61992008,
34            0.61992008, 0.61992008, 0.61992008, 0.61992008, 0.61992008,
35            0.61992008, 0.61992008, 0.61992008, 0.61992008, 0.61992008,
36            0.61992008, 0.61992008
37    ]),
38    array([
39            0.59334993, 0.612515, 0.60293247, 0.60293247, 0.60293247,
40            0.60293247, 0.60293247, 0.60293247, 0.60293247, 0.60293247,
41            0.60293247, 0.60293247, 0.60293247, 0.60293247, 0.60293247,
42            0.60293247, 0.5701077, 0.6088242, 0.58946595, 0.58946595,
43            0.58946595, 0.58946595, 0.58946595, 0.58946595, 0.58946595,
44            0.58946595, 0.58946595, 0.58946595, 0.58946595, 0.58946595,
45            0.58946595, 0.58946595
46    ])
47]

Error – 1 –

In [2]:
 1import numpy as np
 2from oceanai.modules.lab.audio import Audio
 3
 4audio = Audio(lang = 'en')
 5
 6arr_hc = np.array([
 7    [0.64113516, 0.6217892, 0.54451424, 0.6144415],
 8    [0.6652424, 0.63606125, 0.572305, 0.63169795, 0.612515]
 9])
10
11arr_melspectrogram = np.array([
12    [0.56030345, 0.7488746, 0.44648764, 0.59893465, 0.5701077],
13    [0.5900006, 0.7652722, 0.4795154, 0.6409055, 0.6088242]
14])
15
16audio._Audio__concat_pred(
17    pred_hc = arr_hc,
18    pred_melspectrogram = arr_melspectrogram,
19    out = True
20)
[3]:
1[2022-10-20 22:33:31] Something went wrong ... concatenation of scores by hand-crafted and deep features was not performed (audio modality) ...
2
3[]
__load_audio_model_b5(show_summary: bool = False, out: bool = True) Module | None

Formation of the neural network architecture of the model to obtain the personality traits scores

Note

private method

Parameters:
  • show_summary (bool) – Displaying the formed neural network architecture of the model

  • out (bool) – Display

Returns:

None если неверные типы или значения аргументов, в обратном случае нейросетевая модель nn.Module для получения результата оценки персонального качества

Return type:

Optional[nn.Module]

Examples

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio._Audio__load_audio_model_b5(
6    show_summary = True, out = True
7)
[1]:
1audio_model_b5(
2    (fc): Linear(in_features=32, out_features=1, bias=True)
3    (sigmoid): Sigmoid()
4)
5audio_model_b5(
6    (fc): Linear(in_features=32, out_features=1, bias=True)
7    (sigmoid): Sigmoid()
8)

Error – 1 –

In [2]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio._Audio__load_audio_model_b5(
6    show_summary = True, out = []
7)
[3]:
1[2022-10-17 10:53:03] Invalid argument types or values in "Audio.__load_audio_model_b5" ...
__load_model_weights(url: str, force_reload: bool = True, info_text: str = '', out: bool = True, runtime: bool = True, run: bool = True) bool

Downloading the weights of the neural network model

Note

private method

Parameters:
  • url (str) – Full path to the file with weights of the neural network model

  • force_reload (bool) – Forced download of a file with weights of a neural network model from the network

  • info_text (str) – Text for informational message

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if the weights of the neural network model are downloaded, otherwise False

Return type:

bool

Examples

True – 1 –

In [1]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5audio.path_to_save_ = './models'
 6audio.chunk_size_ = 2000000
 7
 8audio._Audio__load_model_weights(
 9    url = 'https://download.sberdisk.ru/download/file/400635799?token=MMRrak8fMsyzxLE&filename=weights_2022-05-05_11-27-55.h5',
10    force_reload = True,
11    info_text = 'Downloading the weights of the neural network model',
12    out = True, runtime = True, run = True
13)
[1]:
1[2022-10-17 12:21:48] Downloading the weights of the neural network model
2
3[2022-10-17 12:21:48] File download "weights_2022-05-05_11-27-55.h5" (100.0%) ...
4
5--- Runtime: 0.439 sec. ---
6
7True

– 2 –

In [2]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5audio.path_to_save_ = './models'
 6audio.chunk_size_ = 2000000
 7
 8audio._Audio__load_model_weights(
 9    url = './models/weights_2022-05-05_11-27-55.h5',
10    force_reload = True,
11    info_text = 'Downloading the weights of the neural network model',
12    out = True, runtime = True, run = True
13)
[2]:
1[2022-10-17 12:21:50] Downloading the weights of the neural network model
2
3--- Runtime: 0.002 sec. ---
4
5True

Error – 1 –

In [3]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5audio.path_to_save_ = './models'
 6audio.chunk_size_ = 2000000
 7
 8audio._Audio__load_model_weights(
 9    url = 'https://download.sberdisk.ru/download/file/400635799?token=MMRrak8fMsyzxLE&filename=weights_2022-05-05_11-27-55.h5',
10    force_reload = True, info_text = '',
11    out = True, runtime = True, run = True
12)
[3]:
1[2022-10-17 12:21:57] Invalid argument types or values in "Audio.__load_model_weights" ...
2
3False
__norm_pred(pred_data: ndarray, len_spec: int = 16, out: bool = True) ndarray

Normalization of scores by hand-crafted and deep features

Note

private method

Parameters:
  • pred_data (np.ndarray) – Scores

  • len_spec (int) – The maximum size of the scores vector

  • out (bool) – Display

Returns:

Normalized scores by hand-crafted and deep features

Return type:

np.ndarray

Examples

True – 1 –

In [1]:
 1import numpy as np
 2from oceanai.modules.lab.audio import Audio
 3
 4audio = Audio()
 5
 6arr = np.array([
 7    [0.64113516, 0.6217892, 0.54451424, 0.6144415, 0.59334993],
 8    [0.6652424, 0.63606125, 0.572305, 0.63169795, 0.612515]
 9])
10
11audio._Audio__norm_pred(
12    pred_data = arr,
13    len_spec = 4,
14    out = True
15)
[1]:
1array([
2    [0.64113516, 0.6217892 , 0.54451424, 0.6144415 , 0.59334993],
3    [0.6652424 , 0.63606125, 0.572305  , 0.63169795, 0.612515],
4    [0.65318878, 0.62892523, 0.55840962, 0.62306972, 0.60293247],
5    [0.65318878, 0.62892523, 0.55840962, 0.62306972, 0.60293247]
6])

Error – 1 –

In [2]:
 1import numpy as np
 2from oceanai.modules.lab.audio import Audio
 3
 4audio = Audio(lang = 'en')
 5
 6arr = np.array([])
 7
 8audio._Audio__norm_pred(
 9    pred_data = arr,
10    len_spec = 4,
11    out = True
12)
[3]:
1[2022-10-20 22:03:17] Invalid argument types or values in "Audio.__norm_pred" ...
2
3array([], dtype=float64)
__smile() Smile

Extracting OpenSmile features

Note

private method

Returns:

Extracted OpenSmile features

Return type:

opensmile.core.smile.Smile

Example

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4audio._Audio__smile()
[1]:
 1{
 2    '$opensmile.core.smile.Smile': {
 3        'feature_set': 'eGeMAPSv02',
 4        'feature_level': 'LowLevelDescriptors',
 5        'options': {},
 6        'sampling_rate': None,
 7        'channels': [0],
 8        'mixdown': False,
 9        'resample': False
10    }
11}
_get_acoustic_features(path: str, sr: int = 44100, window: int | float = 2.0, step: int | float = 1.0, last: bool = False, out: bool = True, runtime: bool = True, run: bool = True) Tuple[List[ndarray | None], List[ndarray | None]][source]

Extracting features from an acoustic signal (without clearing the message output history in a Jupyter cell)

Note

protected method

Parameters:
  • path (str) – Path to the audio or video file

  • sr (int) – Sampling frequency

  • window (Union[int, float]) – Signal segment window size (in seconds)

  • step (Union[int, float]) – Signal segment window shift step (in seconds)

  • last (bool) – Replacing the last message

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

Tuple with two lists: 1. List with hand-crafted features 2. List with mel-spectrograms

Return type:

Tuple[List[Optional[np.ndarray]], List[Optional[np.ndarray]]]

Examples

True – 1 –

In [1]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5sr = 44100
 6path = '/Users/dl/GitHub/oceanai/oceanai/dataset/test80_01/glgfB3vFewc.004.mp4'
 7
 8hc_features, melspectrogram_features = audio._get_acoustic_features(
 9    path = path, sr = sr,
10    window = 2, step = 1,
11    last = False, out = True,
12    runtime = True, run = True
13)
[1]:
 1[2022-10-19 14:58:19] Extraction of features (hand-crafted and mel-spectrograms) from an acoustic signal ...
 2
 3[2022-10-19 14:58:20] Statistics of the features extracted from the acoustic signal:
 4    Total number of segments with:
 5    1. hand-crafted features: 12
 6    2. mel-spectrogram log: 12
 7    Dimension of the matrix of hand-crafted features of one segment: 196 ✕ 25
 8    Dimension of the tensor with log mel-spectrograms of one segment: 224 ✕ 224 ✕ 3
 9
10--- Runtime: 1.273 sec. ---

Errors – 1 –

In [2]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5sr = 44100
 6path = '/Users/dl/GitHub/oceanai/oceanai/dataset/test80_01/glgfB3vFewc.004.mp4'
 7
 8hc_features, melspectrogram_features = audio._get_acoustic_features(
 9    path = 1, sr = sr,
10    window = 2, step = 1,
11    last = False, out = True,
12    runtime = True, run = True
13)
[2]:
1[2022-10-19 15:33:04] Invalid argument types or values in "Audio._get_acoustic_features" ...

– 2 –

In [2]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5sr = 44100
 6path = '/Users/dl/GitHub/oceanai/oceanai/dataset/test80_01/glgfB3vFewc.004.mp4'
 7
 8hc_features, melspectrogram_features = audio._get_acoustic_features(
 9    path = path, sr = sr,
10    window = 0.04, step = 1,
11    last = False, out = True,
12    runtime = True, run = True
13)
[2]:
 1[2022-10-19 15:34:38] Extraction of features (hand-crafted and mel-spectrograms) from an acoustic signal ...
 2
 3[2022-10-19 15:34:38] Something went wrong ... the size (0.04) of the signal segment window is too small ...
 4
 5    File: /Users/dl/GitHub/oceanai/oceanai/modules/lab/audio.py
 6    Line: 863
 7    Method: _get_acoustic_features
 8    Error type: IsSmallWindowSizeError
 9
10--- Runtime: 0.049 sec. ---
property audio_model_hc_: Module | None

Получение нейросетевой модели nn.Module для получения оценок по экспертным признакам

Returns:

Нейросетевая модель nn.Module или None

Return type:

Optional[nn.Module]

Examples

True – 1 –

In [1]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5audio.load_audio_model_hc(
 6    show_summary = False, out = True,
 7    runtime = True, run = True
 8)
 9
10audio.audio_model_hc_
[1]:
 1[2024-10-06 22:49:58] Формирование нейросетевой архитектуры модели для получения оценок по экспертным признакам (аудио модальность) ...
 2
 3--- Время выполнения: 0.011 сек. ---
 4
 5audio_model_hc(
 6    (lstm1): LSTM(25, 64, batch_first=True)
 7    (dropout1): Dropout(p=0.2, inplace=False)
 8    (lstm2): LSTM(64, 128, batch_first=True)
 9    (dropout2): Dropout(p=0.2, inplace=False)
10    (fc): Linear(in_features=128, out_features=5, bias=True)
11)

Error – 1 –

In [2]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio.audio_model_hc_
[2]:
1
property audio_model_nn_: Module | None

Получение нейросетевой модели nn.Module для получения оценок по нейросетевым признакам

Returns:

Нейросетевая модель nn.Module или None

Return type:

Optional[nn.Module]

Examples

True – 1 –

In [1]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5audio.load_audio_model_nn(
 6    show_summary = False, out = True,
 7    runtime = True, run = True
 8)
 9
10audio.audio_model_nn_
[1]:
 1[2024-10-06 22:57:46] Формирование нейросетевой архитектуры для получения оценок по нейросетевым признакам (аудио модальность) ...
 2
 3--- Время выполнения: 1.59 сек. ---
 4
 5audio_model_nn(
 6(vgg): VGG(
 7    (features): Sequential(
 8    (0): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
 9    (1): ReLU(inplace=True)
10    (2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
11    (3): ReLU(inplace=True)
12    (4): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
13    (5): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
14    (6): ReLU(inplace=True)
15    (7): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
16    (8): ReLU(inplace=True)
17    (9): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
18    (10): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
19    (11): ReLU(inplace=True)
20    (12): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
21    (13): ReLU(inplace=True)
22    (14): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
23    (15): ReLU(inplace=True)
24    (16): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
25    (17): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
26    (18): ReLU(inplace=True)
27    (19): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
28    (20): ReLU(inplace=True)
29    (21): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
30    (22): ReLU(inplace=True)
31    (23): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
32    (24): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
33    (25): ReLU(inplace=True)
34    (26): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
35    (27): ReLU(inplace=True)
36    (28): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
37    (29): ReLU(inplace=True)
38    (30): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
39    )
40    (avgpool): AdaptiveAvgPool2d(output_size=(7, 7))
41    (classifier): Identity()
42)
43(flatten): Flatten(start_dim=1, end_dim=-1)
44(fc1): Linear(in_features=25088, out_features=512, bias=True)
45(relu): ReLU()
46(dropout): Dropout(p=0.5, inplace=False)
47(fc2): Linear(in_features=512, out_features=256, bias=True)
48(fc3): Linear(in_features=256, out_features=5, bias=True)
49)

Error – 1 –

In [2]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio.audio_model_nn_
[2]:
1
property audio_models_b5_: Dict[str, Module | None]

Получение нейросетевых моделей nn.Module для получения результатов оценки персональных качеств

Returns:

Словарь с нейросетевыми моделями nn.Module

Return type:

Dict

Examples

True – 1 –

In [1]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5audio.load_audio_models_b5(
 6    show_summary = False, out = True,
 7    runtime = True, run = True
 8)
 9
10audio.audio_models_b5_
[1]:
 1[2024-10-06 22:58:27] Формирование нейросетевых архитектур моделей для получения результатов оценки персональных качеств (аудио модальность) ...
 2
 3--- Время выполнения: 0.002 сек. ---
 4
 5{'openness': audio_model_b5(
 6    (fc): Linear(in_features=32, out_features=1, bias=True)
 7    (sigmoid): Sigmoid()
 8),
 9'conscientiousness': audio_model_b5(
10    (fc): Linear(in_features=32, out_features=1, bias=True)
11    (sigmoid): Sigmoid()
12),
13'extraversion': audio_model_b5(
14    (fc): Linear(in_features=32, out_features=1, bias=True)
15    (sigmoid): Sigmoid()
16),
17'agreeableness': audio_model_b5(
18    (fc): Linear(in_features=32, out_features=1, bias=True)
19    (sigmoid): Sigmoid()
20),
21'non-neuroticism': audio_model_b5(
22    (fc): Linear(in_features=32, out_features=1, bias=True)
23    (sigmoid): Sigmoid()
24)}

Error – 1 –

In [2]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio.audio_models_b5_
[2]:
1{
2    'openness': None,
3    'conscientiousness': None,
4    'extraversion': None,
5    'agreeableness': None,
6    'non_neuroticism': None
7}
get_acoustic_features(path: str, sr: int = 44100, window: int | float = 2.0, step: int | float = 1.0, out: bool = True, runtime: bool = True, run: bool = True) Tuple[List[ndarray | None], List[ndarray | None]][source]

Extracting features from an acoustic signal

Parameters:
  • path (str) – Path to the audio or video file

  • sr (int) – Sampling frequency

  • window (Union[int, float]) – Signal segment window size (in seconds)

  • step (Union[int, float]) – Signal segment window shift step (in seconds)

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

Tuple with two lists: 1. List with hand-crafted features 2. List with mel-spectrograms

Return type:

Tuple[List[Optional[np.ndarray]], List[Optional[np.ndarray]]]

Example

get_audio_union_predictions(depth: int = 1, recursive: bool = False, sr: int = 44100, window: int | float = 2.0, step: int | float = 1.0, accuracy=True, url_accuracy: str = '', logs: bool = True, out: bool = True, runtime: bool = True, run: bool = True) bool[source]

Get audio scores

Parameters:
  • depth (int) – Hierarchy depth for getting data

  • recursive (bool) – Recursive data search

  • sr (int) – Sampling frequency

  • window (Union[int, float]) – Signal segment window size (in seconds)

  • step (Union[int, float]) – Signal segment window shift step (in seconds)

  • accuracy (bool) – Accuracy calculation

  • url_accuracy (str) – Full path to the file with ground truth scores for calculating accuracy

  • logs (bool) – If necessary, generate a LOG file

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if scores are successfully received, otherwise False

Return type:

bool

Example

load_audio_model_hc(show_summary: bool = False, out: bool = True, runtime: bool = True, run: bool = True) bool[source]

Formation of the neural network architecture of the model for obtaining scores by hand-crafted features

Parameters:
  • show_summary (bool) – Displaying the formed neural network architecture of the model

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if the neural network architecture of the model is formed, otherwise False

Return type:

bool

Examples

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4audio.load_audio_model_hc(
5    show_summary = False, out = True,
6    runtime = True, run = True
7)
[1]:
1[2022-10-17 13:16:23] Formation of the neural network architecture of the model for obtaining scores by hand-crafted features (audio modality) ...
2
3--- Runtime: 0.364 sec. ---
4
5True

Error – 1 –

In [2]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4audio.load_audio_model_hc(
5    show_summary = 1, out = True,
6    runtime = True, run = True
7)
[2]:
1[2022-10-17 13:20:04] Invalid argument types or values in "Audio.load_audio_model_hc" ...
2
3False
load_audio_model_nn(show_summary: bool = False, out: bool = True, runtime: bool = True, run: bool = True) bool[source]

Formation of a neural network architecture for obtaining scores by deep features

Parameters:
  • show_summary (bool) – Displaying the formed neural network architecture of the model

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if the neural network architecture of the model is formed, otherwise False

Return type:

bool

Examples

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio()
4
5audio.load_audio_model_nn(
6    show_summary = True, out = True,
7    runtime = True, run = True
8)
[1]:
 1[2024-10-06 23:01:20] Формирование нейросетевой архитектуры для получения оценок по нейросетевым признакам (аудио модальность) ...
 2
 3audio_model_nn(
 4(vgg): VGG(
 5    (features): Sequential(
 6    (0): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
 7    (1): ReLU(inplace=True)
 8    (2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
 9    (3): ReLU(inplace=True)
10    (4): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
11    (5): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
12    (6): ReLU(inplace=True)
13    (7): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
14    (8): ReLU(inplace=True)
15    (9): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
16    (10): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
17    (11): ReLU(inplace=True)
18    (12): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
19    (13): ReLU(inplace=True)
20    (14): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
21    (15): ReLU(inplace=True)
22    (16): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
23    (17): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
24    (18): ReLU(inplace=True)
25    (19): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
26    (20): ReLU(inplace=True)
27    (21): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
28    (22): ReLU(inplace=True)
29    (23): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
30    (24): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
31    (25): ReLU(inplace=True)
32    (26): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
33    (27): ReLU(inplace=True)
34    (28): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
35    (29): ReLU(inplace=True)
36    (30): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
37    )
38    (avgpool): AdaptiveAvgPool2d(output_size=(7, 7))
39    (classifier): Identity()
40)
41(flatten): Flatten(start_dim=1, end_dim=-1)
42(fc1): Linear(in_features=25088, out_features=512, bias=True)
43(relu): ReLU()
44(dropout): Dropout(p=0.5, inplace=False)
45(fc2): Linear(in_features=512, out_features=256, bias=True)
46(fc3): Linear(in_features=256, out_features=5, bias=True)
47)
48--- Время выполнения: 1.958 сек. ---
49
50True

Error – 1 –

In [2]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4audio.load_audio_model_nn(
5    show_summary = 1, out = True,
6    runtime = True, run = True
7)
[2]:
1[2022-10-17 13:25:40] Invalid argument types or values in "Audio.load_audio_model_nn" ...
2
3False
load_audio_model_weights_hc(url: str, force_reload: bool = True, out: bool = True, runtime: bool = True, run: bool = True) bool[source]

Downloading the weights of the neural network model to obtain scores by hand-crafted features

Parameters:
  • url (str) – Full path to the file with weights of the neural network model

  • force_reload (bool) – Forced download of a file with weights of a neural network model from the network

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if the weights of the neural network model are downloaded, otherwise False

Return type:

bool

Examples

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio.load_audio_model_hc(
6    show_summary = False, out = True,
7    runtime = True, run = True
8)
[1]:
1[2022-10-17 14:24:28] Formation of the neural network architecture of the model for obtaining scores by hand-crafted features (audio modality) ...
2
3--- Runtime: 0.398 sec. ---
4
5True
In [2]:
 1audio.path_to_save_ = './models'
 2audio.chunk_size_ = 2000000
 3
 4url = audio.weights_for_big5_['audio']['fi']['hc']['googledisk']
 5
 6audio.load_audio_model_weights_hc(
 7    url = url,
 8    force_reload = True,
 9    out = True,
10    runtime = True,
11    run = True
12)
[2]:
1[2024-10-06 23:05:53] Загрузка весов нейросетевой модели для получения оценок по экспертным признакам (аудио модальность) ...
2
3[2024-10-06 23:05:56] Загрузка файла "weights_2022-05-05_11-27-55.pth" 100.0% ...
4
5--- Время выполнения: 3.078 сек. ---
6
7True

Error – 1 –

In [3]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio()
 4
 5audio.path_to_save_ = './models'
 6audio.chunk_size_ = 2000000
 7
 8url = audio.weights_for_big5_['audio']['fi']['hc']['googledisk']
 9
10audio.load_audio_model_weights_hc(
11    url = url,
12    force_reload = True,
13    out = True,
14    runtime = True,
15    run = True
16)
[3]:
1[2024-10-06 23:07:25] Загрузка весов нейросетевой модели для получения оценок по экспертным признакам (аудио модальность) ...
2
3[2024-10-06 23:07:28] Загрузка файла "weights_2022-05-05_11-27-55.pth" 100.0% ...
4
5[2024-10-06 23:07:28] Что-то пошло не так ... нейросетевая архитектура модели для получения оценок по экспертным признакам не сформирована (аудио модальность) ...
6
7--- Время выполнения: 2.911 сек. ---
8
9False
load_audio_model_weights_nn(url: str, force_reload: bool = True, out: bool = True, runtime: bool = True, run: bool = True) bool[source]

Downloading the weights of the neural network model to obtain scores for deep features

Parameters:
  • url (str) – Full path to the file with weights of the neural network model

  • force_reload (bool) – Forced download of a file with weights of a neural network model from the network

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if the weights of the neural network model are downloaded, otherwise False

Return type:

bool

Examples

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio.load_audio_model_nn(
6    show_summary = False, out = True,
7    runtime = True, run = True
8)
[1]:
1[2022-10-17 15:47:20] Formation of a neural network architecture for obtaining scores by deep features (audio modality) ...
2
3--- Runtime: 0.419 sec. ---
4
5True
In [2]:
 1audio.path_to_save_ = './models'
 2audio.chunk_size_ = 2000000
 3
 4url = audio.weights_for_big5_['audio']['fi']['nn']['googledisk']
 5
 6audio.load_audio_model_weights_nn(
 7    url = url,
 8    force_reload = True,
 9    out = True,
10    runtime = True,
11    run = True
12)
[2]:
1[2024-10-06 23:22:33] Загрузка весов нейросетевой модели для получения оценок по нейросетевым признакам (аудио модальность) ...
2
3[2024-10-06 23:22:39] Загрузка файла "weights_2022-05-03_07-46-14.pth" 100.0% ...
4
5--- Время выполнения: 6.454 сек. ---
6
7True

Error – 1 –

In [3]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio(lang = 'en')
 4
 5audio.path_to_save_ = './models'
 6audio.chunk_size_ = 2000000
 7
 8url = audio.weights_for_big5_['audio']['nn']['sberdisk']
 9
10audio.load_audio_model_weights_nn(
11    url = url,
12    force_reload = True,
13    out = True,
14    runtime = True,
15    run = True
16)
[3]:
1[2024-10-06 23:23:37] Загрузка весов нейросетевой модели для получения оценок по нейросетевым признакам (аудио модальность) ...
2
3[2024-10-06 23:23:43] Загрузка файла "weights_2022-05-03_07-46-14.pth" 100.0% ...
4
5[2024-10-06 23:23:43] Что-то пошло не так ... нейросетевая архитектура модели для получения оценок по нейросетевым признакам не сформирована (аудио модальность) ...
6
7--- Время выполнения: 5.639 сек. ---
8
9False
load_audio_models_b5(show_summary: bool = False, out: bool = True, runtime: bool = True, run: bool = True) bool[source]

Formation of neural network architectures of models for obtaining the personality traits scores

Parameters:
  • show_summary (bool) – Displaying the last generated neural network architecture of models

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if the neural network architectures of the model are formed, otherwise False

Return type:

bool

Examples

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4audio.load_audio_models_b5(
5    show_summary = True, out = True,
6    runtime = True, run = True
7)
[1]:
1[2024-10-06 23:21:04] Формирование нейросетевых архитектур моделей для получения результатов оценки персональных качеств (аудио модальность) ...
2
3audio_model_b5(
4    (fc): Linear(in_features=32, out_features=1, bias=True)
5    (sigmoid): Sigmoid()
6)
7--- Время выполнения: 0.003 сек. ---
8
9True

Error – 1 –

In [2]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4audio.load_audio_models_b5(
5    show_summary = 1, out = True,
6    runtime = True, run = True
7)
[2]:
1[2022-10-18 13:47:36] Invalid argument types or values in "Audio.load_audio_models_b5" ...
2
3False
load_audio_models_weights_b5(url_openness: str, url_conscientiousness: str, url_extraversion: str, url_agreeableness: str, url_non_neuroticism: str, force_reload: bool = True, out: bool = True, runtime: bool = True, run: bool = True) bool[source]

Downloading the weights of neural network models to obtain the personality traits scores

Parameters:
  • url_openness (str) – Full path to the file with the weights of the neural network model (openness)

  • url_conscientiousness (str) – Full path to the file with the weights of the neural network model (conscientiousness)

  • url_extraversion (str) – Full path to the file with the weights of the neural network model (extraversion)

  • url_agreeableness (str) – Full path to the file with the weights of the neural network model (agreeableness)

  • url_non_neuroticism (str) – Full path to the file with the weights of the neural network model (non-neuroticism)

  • force_reload (bool) – Forced download of files with weights of neural network models from the network

  • out (bool) – Display

  • runtime (bool) – Runtime count

  • run (bool) – Run blocking

Returns:

True if the weights of the neural network models are downloaded, otherwise False

Return type:

bool

Examples

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4
5audio.load_audio_models_b5(
6    show_summary = False, out = True,
7    runtime = True, run = True
8)
[1]:
1[2022-10-18 22:40:05] Formation of neural network architectures of models for obtaining the personality traits scores (audio modality) ...
2
3--- Runtime: 0.163 sec. ---
4
5True
In [2]:
 1audio.path_to_save_ = './models'
 2audio.chunk_size_ = 2000000
 3
 4url_openness = audio.weights_for_big5_['audio']['fi']['b5']['openness']['googledisk']
 5url_conscientiousness = audio.weights_for_big5_['audio']['fi']['b5']['conscientiousness']['googledisk']
 6url_extraversion = audio.weights_for_big5_['audio']['fi']['b5']['extraversion']['googledisk']
 7url_agreeableness = audio.weights_for_big5_['audio']['fi']['b5']['agreeableness']['googledisk']
 8url_non_neuroticism = audio.weights_for_big5_['audio']['fi']['b5']['non_neuroticism']['googledisk']
 9
10audio.load_audio_models_weights_b5(
11    url_openness = url_openness,
12    url_conscientiousness = url_conscientiousness,
13    url_extraversion = url_extraversion,
14    url_agreeableness = url_agreeableness,
15    url_non_neuroticism = url_non_neuroticism,
16    force_reload = True,
17    out = True,
18    runtime = True,
19    run = True
20)
[2]:
 1[2024-10-06 23:15:39] Загрузка весов нейросетевых моделей для получения результатов оценки персональных качеств (аудио модальность) ...
 2
 3[2024-10-06 23:15:42] Загрузка файла "weights_2022-06-15_16-16-20.pth" 100.0% ... Открытость опыту
 4
 5[2024-10-06 23:15:45] Загрузка файла "weights_2022-06-15_16-21-57.pth" 100.0% ... Добросовестность
 6
 7[2024-10-06 23:15:47] Загрузка файла "weights_2022-06-15_16-26-41.pth" 100.0% ... Экстраверсия
 8
 9[2024-10-06 23:15:49] Загрузка файла "weights_2022-06-15_16-32-51.pth" 100.0% ... Доброжелательность
10
11[2024-10-06 23:15:52] Загрузка файла "weights_2022-06-15_16-37-46.pth" 100.0% ... Эмоциональная стабильность
12
13--- Время выполнения: 12.466 сек. ---
14
15True

Error – 1 –

In [3]:
 1from oceanai.modules.lab.audio import Audio
 2
 3audio = Audio()
 4
 5audio.path_to_save_ = './models'
 6audio.chunk_size_ = 2000000
 7
 8url_openness = audio.weights_for_big5_['audio']['fi']['b5']['openness']['googledisk']
 9url_conscientiousness = audio.weights_for_big5_['audio']['fi']['b5']['conscientiousness']['googledisk']
10url_extraversion = audio.weights_for_big5_['audio']['fi']['b5']['extraversion']['googledisk']
11url_agreeableness = audio.weights_for_big5_['audio']['fi']['b5']['agreeableness']['googledisk']
12url_non_neuroticism = audio.weights_for_big5_['audio']['fi']['b5']['non_neuroticism']['googledisk']
13
14audio.load_audio_models_weights_b5(
15    url_openness = url_openness,
16    url_conscientiousness = url_conscientiousness,
17    url_extraversion = url_extraversion,
18    url_agreeableness = url_agreeableness,
19    url_non_neuroticism = url_non_neuroticism,
20    force_reload = True,
21    out = True,
22    runtime = True,
23    run = True
24)
[3]:
 1[2024-10-06 23:17:35] Загрузка весов нейросетевых моделей для получения результатов оценки персональных качеств (аудио модальность) ...
 2
 3[2024-10-06 23:17:37] Загрузка файла "weights_2022-06-15_16-16-20.pth" 100.0% ...
 4
 5[2024-10-06 23:17:37] Что-то пошло не так ... не удалось загрузить веса нейросетевой модели ... Открытость опыту
 6
 7    Файл: /Users/dl/@DmitryRyumin/Python/envs/OCEANAI/lib/python3.9/site-packages/oceanai/modules/lab/audio.py
 8    Линия: 2284
 9    Метод: load_audio_models_weights_b5
10    Тип ошибки: AttributeError
11
12[2024-10-06 23:17:40] Загрузка файла "weights_2022-06-15_16-21-57.pth" 100.0% ...
13
14[2024-10-06 23:17:40] Что-то пошло не так ... не удалось загрузить веса нейросетевой модели ... Добросовестность
15
16    Файл: /Users/dl/@DmitryRyumin/Python/envs/OCEANAI/lib/python3.9/site-packages/oceanai/modules/lab/audio.py
17    Линия: 2284
18    Метод: load_audio_models_weights_b5
19    Тип ошибки: AttributeError
20
21[2024-10-06 23:17:42] Загрузка файла "weights_2022-06-15_16-26-41.pth" 100.0% ...
22
23[2024-10-06 23:17:42] Что-то пошло не так ... не удалось загрузить веса нейросетевой модели ... Экстраверсия
24
25    Файл: /Users/dl/@DmitryRyumin/Python/envs/OCEANAI/lib/python3.9/site-packages/oceanai/modules/lab/audio.py
26    Линия: 2284
27    Метод: load_audio_models_weights_b5
28    Тип ошибки: AttributeError
29
30[2024-10-06 23:17:45] Загрузка файла "weights_2022-06-15_16-32-51.pth" 100.0% ...
31
32[2024-10-06 23:17:45] Что-то пошло не так ... не удалось загрузить веса нейросетевой модели ... Доброжелательность
33
34    Файл: /Users/dl/@DmitryRyumin/Python/envs/OCEANAI/lib/python3.9/site-packages/oceanai/modules/lab/audio.py
35    Линия: 2284
36    Метод: load_audio_models_weights_b5
37    Тип ошибки: AttributeError
38
39[2024-10-06 23:17:47] Загрузка файла "weights_2022-06-15_16-37-46.pth" 100.0% ...
40
41[2024-10-06 23:17:47] Что-то пошло не так ... не удалось загрузить веса нейросетевой модели ... Эмоциональная стабильность
42
43    Файл: /Users/dl/@DmitryRyumin/Python/envs/OCEANAI/lib/python3.9/site-packages/oceanai/modules/lab/audio.py
44    Линия: 2284
45    Метод: load_audio_models_weights_b5
46    Тип ошибки: AttributeError
47
48--- Время выполнения: 12.562 сек. ---
49
50False
property smile_: Smile

Getting OpenSmile functions

Returns:

Extracted OpenSmile features

Return type:

opensmile.core.smile.Smile

Example

True – 1 –

In [1]:
1from oceanai.modules.lab.audio import Audio
2
3audio = Audio(lang = 'en')
4audio.smile_
[1]:
 1{
 2    '$opensmile.core.smile.Smile': {
 3        'feature_set': 'eGeMAPSv02',
 4        'feature_level': 'LowLevelDescriptors',
 5        'options': {},
 6        'sampling_rate': None,
 7        'channels': [0],
 8        'mixdown': False,
 9        'resample': False
10    }
11}