sonusai 1.0.17__cp311-abi3-macosx_10_12_x86_64.whl → 1.0.18__cp311-abi3-macosx_10_12_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sonusai/datatypes.py +21 -4
- sonusai/parse/choose.py +68 -0
- sonusai/parse/sequence.py +50 -0
- sonusai/rs.abi3.so +0 -0
- {sonusai-1.0.17.dist-info → sonusai-1.0.18.dist-info}/METADATA +1 -1
- {sonusai-1.0.17.dist-info → sonusai-1.0.18.dist-info}/RECORD +8 -6
- {sonusai-1.0.17.dist-info → sonusai-1.0.18.dist-info}/WHEEL +0 -0
- {sonusai-1.0.17.dist-info → sonusai-1.0.18.dist-info}/entry_points.txt +0 -0
sonusai/datatypes.py
CHANGED
@@ -88,16 +88,33 @@ class Effects(DataClassSonusAIMixin):
|
|
88
88
|
|
89
89
|
class UniversalSNRGenerator:
|
90
90
|
def __init__(self, raw_value: float | str) -> None:
|
91
|
-
|
92
|
-
|
91
|
+
from sonusai.parse.choose import parse_choose_expression
|
92
|
+
from sonusai.parse.sequence import parse_sequence_expression
|
93
|
+
|
94
|
+
self.is_random = False
|
95
|
+
self._rand_obj = None
|
96
|
+
|
97
|
+
if isinstance(raw_value, str) and raw_value.startswith("rand"):
|
98
|
+
self.is_random = True
|
99
|
+
self._rand_directive = str(raw_value)
|
100
|
+
elif isinstance(raw_value, str) and raw_value.startswith("choose"):
|
101
|
+
self._rand_obj = parse_choose_expression(raw_value)
|
102
|
+
elif isinstance(raw_value, str) and raw_value.startswith("sequence"):
|
103
|
+
self._rand_obj = parse_sequence_expression(raw_value)
|
104
|
+
else:
|
105
|
+
self._raw_value = float(raw_value)
|
93
106
|
|
94
107
|
@property
|
95
108
|
def value(self) -> float:
|
96
109
|
from sonusai.parse.rand import rand
|
97
110
|
|
98
111
|
if self.is_random:
|
99
|
-
return float(rand(self.
|
100
|
-
|
112
|
+
return float(rand(self._rand_directive))
|
113
|
+
|
114
|
+
if self._rand_obj:
|
115
|
+
return float(self._rand_obj.next())
|
116
|
+
|
117
|
+
return self._raw_value
|
101
118
|
|
102
119
|
|
103
120
|
class UniversalSNR(float):
|
sonusai/parse/choose.py
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
import pyparsing as pp
|
2
|
+
|
3
|
+
from ..utils.choice import RandomChoice
|
4
|
+
|
5
|
+
|
6
|
+
def parse_choose_expression(expression: str) -> RandomChoice:
|
7
|
+
"""
|
8
|
+
Parse a string of the form "choose([1, 2, 3])" or "choose([1, 2, 3], repetition=True)"
|
9
|
+
and return a RandomChoice object with the parsed list and optional repetition parameter.
|
10
|
+
|
11
|
+
Args:
|
12
|
+
expression: String to parse, e.g., "choose([1, 2, 3])" or "choose([1, 2, 3], repetition=False)"
|
13
|
+
|
14
|
+
Returns:
|
15
|
+
RandomChoice object with parsed data and repetition settings
|
16
|
+
|
17
|
+
Raises:
|
18
|
+
pp.ParseException: If the string doesn't match the expected format
|
19
|
+
"""
|
20
|
+
# Define grammar for parsing numbers, strings, and booleans
|
21
|
+
number = pp.pyparsing_common.number
|
22
|
+
quoted_string = pp.QuotedString('"') | pp.QuotedString("'")
|
23
|
+
boolean = pp.Keyword("True").setParseAction(lambda: True) | pp.Keyword("False").setParseAction(lambda: False)
|
24
|
+
|
25
|
+
# List element can be a number, quoted string, or boolean
|
26
|
+
list_element = number | quoted_string | boolean
|
27
|
+
|
28
|
+
# List definition: [item1, item2, ...]
|
29
|
+
list_def = pp.Suppress("[") + pp.Optional(pp.delimitedList(list_element)) + pp.Suppress("]")
|
30
|
+
|
31
|
+
# Repetition parameter: repetition=True, or repetition=False
|
32
|
+
repetition_param = pp.Keyword("repetition") + pp.Suppress("=") + boolean
|
33
|
+
|
34
|
+
# Function call: choose([...]) or choose([...], repetition=...)
|
35
|
+
function_call = (
|
36
|
+
pp.Keyword("choose")
|
37
|
+
+ pp.Suppress("(")
|
38
|
+
+ list_def
|
39
|
+
+ pp.Optional(pp.Suppress(",") + repetition_param)
|
40
|
+
+ pp.Suppress(")")
|
41
|
+
)
|
42
|
+
|
43
|
+
# Parse the expression
|
44
|
+
try:
|
45
|
+
result = function_call.parseString(expression, parseAll=True)
|
46
|
+
|
47
|
+
# Extract the list (everything between 'choose' and potential 'repetition')
|
48
|
+
data_list = []
|
49
|
+
repetition: bool = False
|
50
|
+
|
51
|
+
for item in result:
|
52
|
+
if item == "choose":
|
53
|
+
continue
|
54
|
+
elif item == "repetition":
|
55
|
+
break
|
56
|
+
else:
|
57
|
+
data_list.append(item)
|
58
|
+
|
59
|
+
# If repetition was specified, find its value
|
60
|
+
if "repetition" in result.as_list():
|
61
|
+
repetition_index = result.asList().index("repetition")
|
62
|
+
if repetition_index + 1 < len(result):
|
63
|
+
repetition = bool(result[repetition_index + 1])
|
64
|
+
|
65
|
+
return RandomChoice(data_list, repetition=repetition)
|
66
|
+
|
67
|
+
except pp.ParseException as e:
|
68
|
+
raise pp.ParseException(f"Invalid choose expression format: {e}") from e
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import pyparsing as pp
|
2
|
+
|
3
|
+
from ..utils.choice import SequentialChoice
|
4
|
+
|
5
|
+
|
6
|
+
def parse_sequence_expression(expression: str) -> SequentialChoice:
|
7
|
+
"""
|
8
|
+
Parse a string of the form "sequence([1, 2, 3])"
|
9
|
+
and return a SequentialChoice object with the parsed list.
|
10
|
+
|
11
|
+
Args:
|
12
|
+
expression: String to parse, e.g., "sequence([1, 2, 3])"
|
13
|
+
|
14
|
+
Returns:
|
15
|
+
SequentialChoice object with parsed data
|
16
|
+
|
17
|
+
Raises:
|
18
|
+
pp.ParseException: If the string doesn't match the expected format
|
19
|
+
"""
|
20
|
+
# Define grammar for parsing numbers, strings, and booleans
|
21
|
+
number = pp.pyparsing_common.number
|
22
|
+
quoted_string = pp.QuotedString('"') | pp.QuotedString("'")
|
23
|
+
boolean = pp.Keyword("True").setParseAction(lambda: True) | pp.Keyword("False").setParseAction(lambda: False)
|
24
|
+
|
25
|
+
# List element can be a number, quoted string, or boolean
|
26
|
+
list_element = number | quoted_string | boolean
|
27
|
+
|
28
|
+
# List definition: [item1, item2, ...]
|
29
|
+
list_def = pp.Suppress("[") + pp.Optional(pp.delimitedList(list_element)) + pp.Suppress("]")
|
30
|
+
|
31
|
+
# Function call: sequence([...])
|
32
|
+
function_call = pp.Keyword("sequence") + pp.Suppress("(") + list_def + pp.Suppress(")")
|
33
|
+
|
34
|
+
# Parse the expression
|
35
|
+
try:
|
36
|
+
result = function_call.parseString(expression, parseAll=True)
|
37
|
+
|
38
|
+
# Extract the list (everything after 'sequence')
|
39
|
+
data_list = []
|
40
|
+
|
41
|
+
for item in result:
|
42
|
+
if item == "sequence":
|
43
|
+
continue
|
44
|
+
else:
|
45
|
+
data_list.append(item)
|
46
|
+
|
47
|
+
return SequentialChoice(data_list)
|
48
|
+
|
49
|
+
except pp.ParseException as e:
|
50
|
+
raise pp.ParseException(f"Invalid sequence expression format: {e}") from e
|
sonusai/rs.abi3.so
CHANGED
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
sonusai-1.0.
|
2
|
-
sonusai-1.0.
|
3
|
-
sonusai-1.0.
|
1
|
+
sonusai-1.0.18.dist-info/METADATA,sha256=WuFcKlPEE4bBZHdWqvgRbX4vUS-H9N6Aeu4WfjEdIng,2601
|
2
|
+
sonusai-1.0.18.dist-info/WHEEL,sha256=4-MxxhqCDAoFQQ2gzyecUreXPLf07ql-PG7vniU0rIA,105
|
3
|
+
sonusai-1.0.18.dist-info/entry_points.txt,sha256=gw3C7Ih4fM4oJThb-dkERhdDtDzEHr6kZZVRVX0rkMk,91
|
4
4
|
sonusai/mkwav.py,sha256=9fBlm14GlBCkz-hXvaM3rva2iVVSzQ45G7G0vmfP-wc,4309
|
5
5
|
sonusai/metrics/calculate_metrics.py,sha256=jcAyEV6loenu4fU_EvwEkpKxOrP8-K9O3rwQGlE48IU,12475
|
6
6
|
sonusai/metrics/calc_phase_distance.py,sha256=MFuBtGXb5qfQvRVciJ0Soz1w0GMSeJLBJud-aK4Loow,1870
|
@@ -36,7 +36,9 @@ sonusai/config/config.yml,sha256=Z7D4adzaK1TAUJyEJdjE-xdg67kHis4WXZ5UjAmyW2Q,804
|
|
36
36
|
sonusai/config/source.py,sha256=hID2BbuaaqKjuJBcRSNTpiA6xtGd-TeSxSjzRDhD0Gc,10761
|
37
37
|
sonusai/genmix.py,sha256=AaROzReE5vSRKZ3zqVOSdCpwANJHRHxQ8fWk6EcEVrE,5851
|
38
38
|
sonusai/rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
|
+
sonusai/parse/choose.py,sha256=zkeTXNSl6h2xV6X01jep2dLvtJv1AjVOHvfma7Nh4aQ,2468
|
39
40
|
sonusai/parse/parse_source_directive.py,sha256=HhQlqKXg6BoHaEGdVK7abRXLz1agi4M4RV-Z9ckuEpQ,4520
|
41
|
+
sonusai/parse/sequence.py,sha256=5j4glQlHPSH3SeyiHtAfxXjwNWm6c32ZkgdNTb9vvAI,1662
|
40
42
|
sonusai/parse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
43
|
sonusai/parse/rand.py,sha256=nKPqbN_w9xnm2_LBlTl1e6AZn4b89McR-CErxt6YBHM,8579
|
42
44
|
sonusai/parse/expand.py,sha256=DAX1crIRKbcM61A7EpQRgvMj_d1ckRRjyl34tYYAQgg,4441
|
@@ -99,7 +101,7 @@ sonusai/speech/vctk.py,sha256=WInvRRRkZCW6t_NcZAJffJzgCbyetal-j2w0kKX5SDw,1527
|
|
99
101
|
sonusai/speech/textgrid.py,sha256=WvsUeamKoYyXBNnNnZgug-xfTiq2Z6RnFc1u0swmqNw,2813
|
100
102
|
sonusai/genmetrics.py,sha256=ekN7gocVNUfopOgxNbU7mTKahL3wSQSUM5wHOgbNtqU,6194
|
101
103
|
sonusai/aawscd_probwrite.py,sha256=2ZhKoe1iFZ3nzbddEkdM93-CsbuJHE_VsuYyXInwaXE,3709
|
102
|
-
sonusai/datatypes.py,sha256=
|
104
|
+
sonusai/datatypes.py,sha256=I9W7TFT2Lw1yugDW9dXwjw8bwqPEZ5tAztHfe0UGX0g,10455
|
103
105
|
sonusai/genmixdb.py,sha256=ptwvhIhyMRhAIpZxNc3wZUosiyI9ZMcm5C4Wf9iL4mo,7043
|
104
106
|
sonusai/lsdb.py,sha256=ochrLiWSdz1GjqX5Xw7JcH93fkt3nNurLY93tlAvJvA,5095
|
105
107
|
sonusai/doc.py,sha256=mq52mun-QORFSZBO4KexLHkL7wjRsQTCiUbr5ZPN1Ts,1151
|
@@ -146,5 +148,5 @@ sonusai/rs.pyi,sha256=Y25n44pyE3vp92MiABKrcK3IWRyQ1JG1rZ4Ufqy2nC0,17
|
|
146
148
|
sonusai/deprecated/plot.py,sha256=m9epn_RQn-EaarABKjjs2m2bGawxIP8o_KBXvx2s89A,17490
|
147
149
|
sonusai/deprecated/tplot.py,sha256=jnOxiGwCQBy7ChkrNfbpwcgh5_L7Hjnkiyq7HL1HXFo,14651
|
148
150
|
sonusai/deprecated/gentcst.py,sha256=QqyloM_JRck5NfIhGfttwkQeFJ9pmfXD0e0riCJCXu8,19964
|
149
|
-
sonusai/rs.abi3.so,sha256=
|
150
|
-
sonusai-1.0.
|
151
|
+
sonusai/rs.abi3.so,sha256=YskCuLNgLPv_8Wqil3aDv996C38spiP5Utkp7bEryxI,432796
|
152
|
+
sonusai-1.0.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|