Skip to content

Commit

Permalink
Added input of model file to the demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorR committed Apr 25, 2019
1 parent 3fe3790 commit 2ab6253
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ While it is meant to be used as a library, a simple command-line tool is
provided as an example. It operates on RAW 16-bit (machine endian) mono
PCM files sampled at 48 kHz. It can be used as:

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

The output is also a 16-bit raw PCM file.
19 changes: 18 additions & 1 deletion examples/rnnoise_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,29 @@ int main(int argc, char **argv) {
DenoiseState **sts;
float max_attenuation;
if (argc < 3) {
fprintf(stderr, "usage: %s <channels> <max attenuation dB>\n", argv[0]);
fprintf(stderr, "usage: %s <channels> <max attenuation dB> [model file]\n", argv[0]);
return 1;
}

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

if (argc >= 4) {
FILE *model_file = fopen(argv[3], "r");
if (!model_file) {
perror(argv[3]);
return 1;
}
model = rnnoise_model_from_file(model_file);
fprintf(stderr, "\n\n\n%p\n\n\n", model);
if (!model) {
perror(argv[3]);
return 1;
}
fclose(model_file);
}

sts = malloc(channels * sizeof(DenoiseState *));
if (!sts) {
perror("malloc");
Expand Down Expand Up @@ -85,5 +100,7 @@ int main(int argc, char **argv) {
rnnoise_destroy(sts[i]);
free(tmp);
free(sts);
if (model)
rnnoise_model_free(model);
return 0;
}

0 comments on commit 2ab6253

Please sign in to comment.