File tree Expand file tree Collapse file tree 3 files changed +109
-70
lines changed Expand file tree Collapse file tree 3 files changed +109
-70
lines changed Original file line number Diff line number Diff line change @@ -40,20 +40,23 @@ int main(int argc, char **argv) {
40
40
int channels ;
41
41
float x [FRAME_SIZE ];
42
42
short * tmp ;
43
+ int sample_rate ;
43
44
RNNModel * model = NULL ;
44
45
DenoiseState * * sts ;
45
46
float max_attenuation ;
46
- if (argc < 3 ) {
47
- fprintf (stderr , "usage: %s <channels> <max attenuation dB> [model]\n" , argv [0 ]);
47
+ if (argc < 4 ) {
48
+ fprintf (stderr , "usage: %s <sample rate> < channels> <max attenuation dB> [model]\n" , argv [0 ]);
48
49
return 1 ;
49
50
}
50
51
51
- channels = atoi (argv [1 ]);
52
+ sample_rate = atoi (argv [1 ]);
53
+ if (sample_rate <= 0 ) sample_rate = 48000 ;
54
+ channels = atoi (argv [2 ]);
52
55
if (channels < 1 ) channels = 1 ;
53
- max_attenuation = pow (10 , - atof (argv [2 ])/10 );
56
+ max_attenuation = pow (10 , - atof (argv [3 ])/10 );
54
57
55
- if (argc >= 4 ) {
56
- model = rnnoise_get_model (argv [3 ]);
58
+ if (argc >= 5 ) {
59
+ model = rnnoise_get_model (argv [4 ]);
57
60
if (!model ) {
58
61
fprintf (stderr , "Model not found!\n" );
59
62
return 1 ;
@@ -73,6 +76,7 @@ int main(int argc, char **argv) {
73
76
for (i = 0 ; i < channels ; i ++ ) {
74
77
sts [i ] = rnnoise_create (model );
75
78
rnnoise_set_param (sts [i ], RNNOISE_PARAM_MAX_ATTENUATION , max_attenuation );
79
+ rnnoise_set_param (sts [i ], RNNOISE_PARAM_SAMPLE_RATE , sample_rate );
76
80
}
77
81
78
82
while (1 ) {
Original file line number Diff line number Diff line change @@ -67,8 +67,17 @@ RNNOISE_EXPORT const char **rnnoise_models(void);
67
67
RNNOISE_EXPORT RNNModel * rnnoise_get_model (const char * name );
68
68
69
69
/* Parameters to a denoise state */
70
+
71
+ /* RNNOISE_PARAM_MAX_ATTENUATION: The maximum attenuation to perform. Note that
72
+ * this is described in terms of *minimum* gain, so for a 20dB maximum
73
+ * attenuation, the correct value is 0.01. */
70
74
#define RNNOISE_PARAM_MAX_ATTENUATION 1
71
75
76
+ /* RNNOISE_PARAM_SAMPLE_RATE: Sets the sample rate. This is just used to decide
77
+ * how to bin the audio so that it matches the bins in the neural network. This
78
+ * does not affect the frame size, which is always 480 samples. */
79
+ #define RNNOISE_PARAM_SAMPLE_RATE 2
80
+
72
81
RNNOISE_EXPORT void rnnoise_set_param (DenoiseState * st , int param , float value );
73
82
74
83
#endif
You can’t perform that action at this time.
0 commit comments