Skip to content

Commit 2ab6253

Browse files
committed
Added input of model file to the demo.
1 parent 3fe3790 commit 2ab6253

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ While it is meant to be used as a library, a simple command-line tool is
1212
provided as an example. It operates on RAW 16-bit (machine endian) mono
1313
PCM files sampled at 48 kHz. It can be used as:
1414

15-
./examples/rnnoise_demo <number of channels> <maximum attenuation> < input.raw > output.raw
15+
./examples/rnnoise_demo <number of channels> <maximum attenuation> [model file] < input.raw > output.raw
1616

1717
The output is also a 16-bit raw PCM file.

examples/rnnoise_demo.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,29 @@ int main(int argc, char **argv) {
4444
DenoiseState **sts;
4545
float max_attenuation;
4646
if (argc < 3) {
47-
fprintf(stderr, "usage: %s <channels> <max attenuation dB>\n", argv[0]);
47+
fprintf(stderr, "usage: %s <channels> <max attenuation dB> [model file]\n", argv[0]);
4848
return 1;
4949
}
5050

5151
channels = atoi(argv[1]);
5252
if (channels < 1) channels = 1;
5353
max_attenuation = pow(10, -atof(argv[2])/10);
5454

55+
if (argc >= 4) {
56+
FILE *model_file = fopen(argv[3], "r");
57+
if (!model_file) {
58+
perror(argv[3]);
59+
return 1;
60+
}
61+
model = rnnoise_model_from_file(model_file);
62+
fprintf(stderr, "\n\n\n%p\n\n\n", model);
63+
if (!model) {
64+
perror(argv[3]);
65+
return 1;
66+
}
67+
fclose(model_file);
68+
}
69+
5570
sts = malloc(channels * sizeof(DenoiseState *));
5671
if (!sts) {
5772
perror("malloc");
@@ -85,5 +100,7 @@ int main(int argc, char **argv) {
85100
rnnoise_destroy(sts[i]);
86101
free(tmp);
87102
free(sts);
103+
if (model)
104+
rnnoise_model_free(model);
88105
return 0;
89106
}

0 commit comments

Comments
 (0)