From b159a97ecd315d31d620c39e70d32c1fd7df125c Mon Sep 17 00:00:00 2001 From: Jacob Sanders <46481567+Faolan-Rad@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:40:33 -0400 Subject: [PATCH] Added file open and close for C# --- include/rnnoise.h | 12 ++++++++++-- src/rnn_reader.c | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/rnnoise.h b/include/rnnoise.h index 4e42b784..1fe79b20 100644 --- a/include/rnnoise.h +++ b/include/rnnoise.h @@ -97,6 +97,16 @@ RNNOISE_EXPORT void rnnoise_destroy(DenoiseState *st); */ RNNOISE_EXPORT float rnnoise_process_frame(DenoiseState *st, float *out, const float *in); +/** + * Load a system file + */ +RNNOISE_EXPORT FILE *rnnoise_system_open_file(const char* filename, const char* mode); + +/** + * Free a system file + */ +RNNOISE_EXPORT int rnnoise_system_close_file(FILE *f); + /** * Load a model from a file * @@ -115,5 +125,3 @@ RNNOISE_EXPORT void rnnoise_model_free(RNNModel *model); } #endif #endif - -#endif diff --git a/src/rnn_reader.c b/src/rnn_reader.c index 2a031db1..85d3b258 100644 --- a/src/rnn_reader.c +++ b/src/rnn_reader.c @@ -42,6 +42,22 @@ #define F_ACTIVATION_SIGMOID 1 #define F_ACTIVATION_RELU 2 +/** + * Load a system file + */ +FILE *rnnoise_system_open_file(const char* filename, const char* mode) +{ + return fopen(filename, mode); +} + +/** + * Free a system file + */ +int rnnoise_system_close_file(FILE *f) +{ + return fclose(f); +} + RNNModel *rnnoise_model_from_file(FILE *f) { int i, in;