Passed
Pull Request — main (#174)
by
unknown
02:24
created

pincer.objects.events.voice_settings   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 158
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 47
dl 0
loc 158
rs 10
c 0
b 0
f 0
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from __future__ import annotations
5
6
from dataclasses import dataclass
7
from enum import Enum, IntEnum, auto
8
from typing import List
9
10
from ...utils.api_object import APIObject
0 ignored issues
show
introduced by
Cannot import 'utils.api_object' due to syntax error 'invalid syntax (<unknown>, line 80)'
Loading history...
Bug introduced by
The name api_object does not seem to exist in module pincer.utils.
Loading history...
11
12
13
@dataclass
14
class AvailableDevices(APIObject):
15
    """
16
    Represents an availabe device for voice settings
17
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
18
    :param id:
19
        id of the available device
20
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
21
    :param name:
22
        name of the available device
23
    """
24
25
    id: str
26
    name: str
27
28
29
@dataclass
30
class VoiceSettingsInput(APIObject):
31
    """
32
    Represents a voice setting input object
33
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
34
    :param device_id:
35
        the device's id
36
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
37
    :param volume:
38
        input voice level (min: 0, max: 100)
39
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
40
    :param available_devices:
41
        array of read-only device objects containing id and name string keys
42
    """
43
44
    device_id: str
45
    volume: float
46
    available_devices: List[AvailableDevices]
47
48
49
VoiceSettingsOutput = VoiceSettingsInput
50
51
52
class VoiceSettingsModeType(Enum):
53
    """Represents a voice settings mode type"""
54
55
    PUSH_TO_TALK = auto()
56
    VOICE_ACTIVITY = auto()
57
58
59
class KeyTypes(IntEnum):
60
    """Represents a key type"""
61
62
    KEYBOARD_KEY = 0
63
    MOUSE_BUTTON = 1
64
    KEYBOARD_MODIFIER_KEY = 2
65
    GAMEPAD_BUTTON = 3
66
67
68
@dataclass
69
class ShortcutKeyCombo(APIObject):
70
    """
71
    Represents a shortcut key combo for the voice mode settings from a user
72
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
73
    :param type:
74
        type of shortcut key combo
75
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
76
    :param code:
77
        key code
78
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
79
    :param name:
80
        key name
81
    """
82
83
    type: KeyTypes
84
    code: int
85
    name: str
86
87
88
@dataclass
89
class VoiceSettingsMode(APIObject):
90
    """
91
    Represents the voice mode settings from a user
92
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
93
    :param type:
94
        voice setting mode type
95
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
96
    :param auto_threshold:
97
        voice activity threshold automatically sets its threshold
98
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
99
    :param threshold:
100
        threshold for voice activity (in dB)
101
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
102
    :param shortcut:
103
        shortcut key combos for PTT
104
    """
105
106
    type: VoiceSettingsModeType
107
    auto_threshold: bool
108
    threshold: float
109
    shortcut: ShortcutKeyCombo
110
    delay: float
111
112
113
@dataclass
0 ignored issues
show
best-practice introduced by
Too many instance attributes (9/7)
Loading history...
114
class VoiceSettingsUpdateEvent(APIObject):
115
    """
116
    Represents a user's voice settings
117
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
118
    :param input:
119
        input settings
120
121
    :param output:
122
        output settings
123
124
    :param mode:
125
        voice mode settings
126
127
    :param automatic_gain_control:
128
        state of automatic gain control
129
130
    :param echo_cancellation:
131
        state of echo cancellation
132
133
    :param noise_suppression:
134
        state of noise suppression
135
136
    :param qos:
137
        state of voice quality of service
138
139
    :param silence_warning:
140
        state of silence warning notice
141
142
    :param deaf:
143
        state of self-deafen
144
145
    :param mute:
146
        state of self-mute
147
    """
148
149
    input: VoiceSettingsInput
150
    output: VoiceSettingsOutput
151
    automatic_gain_control: bool
152
    echo_cancellation: bool
153
    noise_suppression: bool
154
    qos: bool
155
    silence_warning: bool
156
    deaf: bool
157
    mute: bool
158