aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp17
-rw-r--r--METADATA12
-rw-r--r--README6
-rw-r--r--TRAINING-README (renamed from TRAINING)0
-rw-r--r--examples/rnnoise_demo.c4
-rw-r--r--include/rnnoise.h49
-rw-r--r--src/celt_lpc.c2
-rw-r--r--src/denoise.c4
-rw-r--r--src/kiss_fft.c2
-rw-r--r--src/rnn.h2
10 files changed, 87 insertions, 11 deletions
diff --git a/Android.bp b/Android.bp
index db209ae..6c67368 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,3 +1,20 @@
+package {
+ default_applicable_licenses: ["external_rnnoise_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+ name: "external_rnnoise_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-BSD",
+ ],
+ license_text: [
+ "COPYING",
+ ],
+}
+
cc_library_static {
name: "rnnoise_rnn_vad",
// vendor needed for libpreprocessing effects.
diff --git a/METADATA b/METADATA
index eb57da2..b1cf519 100644
--- a/METADATA
+++ b/METADATA
@@ -1,7 +1,5 @@
name: "rnnoise"
-description:
- "Recurrent neural network for audio noise reduction"
-
+description: "Recurrent neural network for audio noise reduction"
third_party {
url {
type: HOMEPAGE
@@ -11,7 +9,11 @@ third_party {
type: GIT
value: "https://github.com/xiph/rnnoise.git"
}
- version: "9acc1e5a633e0961a5895a73204df24744f199b6"
- last_upgrade_date { year: 2020 month: 6 day: 3 }
+ version: "1cbdbcf1283499bbb2230a6b0f126eb9b236defd"
license_type: NOTICE
+ last_upgrade_date {
+ year: 2021
+ month: 2
+ day: 9
+ }
}
diff --git a/README b/README
index 88fc79c..4158a9b 100644
--- a/README
+++ b/README
@@ -12,6 +12,10 @@ 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 <noisy speech> <output denoised>
The output is also a 16-bit raw PCM file.
+
+The latest version of the source is available from
+https://gitlab.xiph.org/xiph/rnnoise . The github repository
+is a convenience copy.
diff --git a/TRAINING b/TRAINING-README
index 86c5a4e..86c5a4e 100644
--- a/TRAINING
+++ b/TRAINING-README
diff --git a/examples/rnnoise_demo.c b/examples/rnnoise_demo.c
index 83d0709..c70343d 100644
--- a/examples/rnnoise_demo.c
+++ b/examples/rnnoise_demo.c
@@ -41,8 +41,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "usage: %s <noisy speech> <output denoised>\n", argv[0]);
return 1;
}
- f1 = fopen(argv[1], "r");
- fout = fopen(argv[2], "w");
+ f1 = fopen(argv[1], "rb");
+ fout = fopen(argv[2], "wb");
while (1) {
short tmp[FRAME_SIZE];
fread(tmp, sizeof(short), FRAME_SIZE, f1);
diff --git a/include/rnnoise.h b/include/rnnoise.h
index 67f0b06..c4215d9 100644
--- a/include/rnnoise.h
+++ b/include/rnnoise.h
@@ -30,6 +30,9 @@
#include <stdio.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
#ifndef RNNOISE_EXPORT
# if defined(WIN32)
@@ -48,18 +51,64 @@
typedef struct DenoiseState DenoiseState;
typedef struct RNNModel RNNModel;
+/**
+ * Return the size of DenoiseState
+ */
RNNOISE_EXPORT int rnnoise_get_size();
+/**
+ * Return the number of samples processed by rnnoise_process_frame at a time
+ */
+RNNOISE_EXPORT int rnnoise_get_frame_size();
+
+/**
+ * Initializes a pre-allocated DenoiseState
+ *
+ * If model is NULL the default model is used.
+ *
+ * See: rnnoise_create() and rnnoise_model_from_file()
+ */
RNNOISE_EXPORT int rnnoise_init(DenoiseState *st, RNNModel *model);
+/**
+ * Allocate and initialize a DenoiseState
+ *
+ * If model is NULL the default model is used.
+ *
+ * The returned pointer MUST be freed with rnnoise_destroy().
+ */
RNNOISE_EXPORT DenoiseState *rnnoise_create(RNNModel *model);
+/**
+ * Free a DenoiseState produced by rnnoise_create.
+ *
+ * The optional custom model must be freed by rnnoise_model_free() after.
+ */
RNNOISE_EXPORT void rnnoise_destroy(DenoiseState *st);
+/**
+ * Denoise a frame of samples
+ *
+ * in and out must be at least rnnoise_get_frame_size() large.
+ */
RNNOISE_EXPORT float rnnoise_process_frame(DenoiseState *st, float *out, const float *in);
+/**
+ * Load a model from a file
+ *
+ * It must be deallocated with rnnoise_model_free()
+ */
RNNOISE_EXPORT RNNModel *rnnoise_model_from_file(FILE *f);
+/**
+ * Free a custom model
+ *
+ * It must be called after all the DenoiseStates referring to it are freed.
+ */
RNNOISE_EXPORT void rnnoise_model_free(RNNModel *model);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/celt_lpc.c b/src/celt_lpc.c
index 5d7ffa4..521351e 100644
--- a/src/celt_lpc.c
+++ b/src/celt_lpc.c
@@ -103,7 +103,7 @@ void celt_fir(
{
opus_val32 sum[4];
sum[0] = SHL32(EXTEND32(x[i ]), SIG_SHIFT);
- sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT),
+ sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT);
sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
sum[3] = SHL32(EXTEND32(x[i+3]), SIG_SHIFT);
xcorr_kernel(rnum, x+i-ord, sum, ord);
diff --git a/src/denoise.c b/src/denoise.c
index d1c21dc..5a62844 100644
--- a/src/denoise.c
+++ b/src/denoise.c
@@ -257,6 +257,10 @@ int rnnoise_get_size() {
return sizeof(DenoiseState);
}
+int rnnoise_get_frame_size() {
+ return FRAME_SIZE;
+}
+
int rnnoise_init(DenoiseState *st, RNNModel *model) {
memset(st, 0, sizeof(*st));
if (model)
diff --git a/src/kiss_fft.c b/src/kiss_fft.c
index 922dacc..d6b9f26 100644
--- a/src/kiss_fft.c
+++ b/src/kiss_fft.c
@@ -39,7 +39,7 @@
#define CUSTOM_MODES
/* The guts header contains all the multiplication and addition macros that are defined for
- complex numbers. It also delares the kf_ internal functions.
+ complex numbers. It also declares the kf_ internal functions.
*/
static void kf_bfly2(
diff --git a/src/rnn.h b/src/rnn.h
index 10329f5..31b962f 100644
--- a/src/rnn.h
+++ b/src/rnn.h
@@ -66,4 +66,4 @@ void compute_gru(const GRULayer *gru, float *state, const float *input);
void compute_rnn(RNNState *rnn, float *gains, float *vad, const float *input);
-#endif /* _MLP_H_ */
+#endif /* RNN_H_ */