@@ -82,19 +82,25 @@ def conditioning_df_to_midi_features(conditioning_df, length=None):
82
82
83
83
def expression_generator_output_to_conditioning_df (expression_generator_outputs ,
84
84
expression_generator_cond ,
85
- frame_size = 0.004 ):
85
+ frame_size = 0.004 ,
86
+ clip_value = True ):
86
87
"""
87
88
Convert expression generator outputs to conditioning_df.
88
89
Args:
89
90
expression_generator_outputs: The output of the expression generator.
90
91
expression_generator_cond: (in dataset data['cond'])
91
92
frame_size: the frame size, in second.
93
+ clip_value: clip the expression generator output between [0, 1].
92
94
93
95
Returns:
94
96
95
97
"""
96
98
expression_generator_outputs = scale_expression_generator_output (
97
99
expression_generator_outputs [0 ])
100
+ if clip_value : # clip the expression generator output between [0, 1].
101
+ expression_generator_outputs = tf .clip_by_value (
102
+ expression_generator_outputs , clip_value_min = 0.0 , clip_value_max = 1.0
103
+ )
98
104
conditioning_dict_keys = CONDITIONING_KEYS
99
105
data_all = []
100
106
onset = 0
@@ -129,7 +135,10 @@ def conditioning_df_to_expression_generator_output(conditioning_df,
129
135
130
136
131
137
def scale_expression_generator_output (output ):
132
- """Scale expression generator output."""
138
+ """Scale expression generator output.
139
+ This function now is useless. But it is a plcaeholder
140
+ if you want to post-process your note expression output.
141
+ """
133
142
scale = np .ones ((1 , output .shape [- 1 ]))
134
143
scale = tf .convert_to_tensor (scale , tf .float32 )
135
144
output /= scale
0 commit comments