From 46c2edc40e4456937418c9e5860b3f2881d543df Mon Sep 17 00:00:00 2001 From: Katsuya Iida Date: Tue, 10 Oct 2023 09:46:23 +0900 Subject: [PATCH] seal classes with IDisposable (#21) --- .gitignore | 3 +++ NeMoOnnxSharp.Example/ModelDownloader.cs | 2 +- NeMoOnnxSharp/EncDecCTCModel.cs | 5 +---- NeMoOnnxSharp/EncDecClassificationModel.cs | 3 +-- NeMoOnnxSharp/FrameVAD.cs | 2 +- NeMoOnnxSharp/SpectrogramGenerator.cs | 3 +-- NeMoOnnxSharp/SpeechRecognizer.cs | 3 +-- NeMoOnnxSharp/Vocoder.cs | 3 +-- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index dfcfd56..fd52b7e 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,6 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ + +# ONNX runtime +*.onnx diff --git a/NeMoOnnxSharp.Example/ModelDownloader.cs b/NeMoOnnxSharp.Example/ModelDownloader.cs index 73a4a07..42d9a68 100644 --- a/NeMoOnnxSharp.Example/ModelDownloader.cs +++ b/NeMoOnnxSharp.Example/ModelDownloader.cs @@ -12,7 +12,7 @@ namespace NeMoOnnxSharp.Example { - internal class ModelDownloader : IDisposable + internal sealed class ModelDownloader : IDisposable { private readonly HttpClient _httpClient; diff --git a/NeMoOnnxSharp/EncDecCTCModel.cs b/NeMoOnnxSharp/EncDecCTCModel.cs index f32241f..5c6d7b6 100644 --- a/NeMoOnnxSharp/EncDecCTCModel.cs +++ b/NeMoOnnxSharp/EncDecCTCModel.cs @@ -6,13 +6,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace NeMoOnnxSharp { - public class EncDecCTCModel : ASRModel, IDisposable + public sealed class EncDecCTCModel : ASRModel, IDisposable { private const string Vocabulary = " abcdefghijklmnopqrstuvwxyz'_"; diff --git a/NeMoOnnxSharp/EncDecClassificationModel.cs b/NeMoOnnxSharp/EncDecClassificationModel.cs index daec4b8..4d17c57 100644 --- a/NeMoOnnxSharp/EncDecClassificationModel.cs +++ b/NeMoOnnxSharp/EncDecClassificationModel.cs @@ -6,11 +6,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; namespace NeMoOnnxSharp { - public class EncDecClassificationModel : ASRModel, IDisposable + public sealed class EncDecClassificationModel : ASRModel, IDisposable { private static readonly string[] SpeechCommandsLabels = new string[] { diff --git a/NeMoOnnxSharp/FrameVAD.cs b/NeMoOnnxSharp/FrameVAD.cs index eafb085..1fe4dbb 100644 --- a/NeMoOnnxSharp/FrameVAD.cs +++ b/NeMoOnnxSharp/FrameVAD.cs @@ -8,7 +8,7 @@ namespace NeMoOnnxSharp { - public class FrameVAD : IDisposable + public sealed class FrameVAD : IDisposable { private readonly int _sampleRate; private readonly int _modelWinLength; diff --git a/NeMoOnnxSharp/SpectrogramGenerator.cs b/NeMoOnnxSharp/SpectrogramGenerator.cs index 80cd9de..e2414e0 100644 --- a/NeMoOnnxSharp/SpectrogramGenerator.cs +++ b/NeMoOnnxSharp/SpectrogramGenerator.cs @@ -7,11 +7,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; namespace NeMoOnnxSharp { - public class SpectrogramGenerator : IDisposable + public sealed class SpectrogramGenerator : IDisposable { private readonly BaseTokenizer _tokenizer; private readonly InferenceSession _inferSess; diff --git a/NeMoOnnxSharp/SpeechRecognizer.cs b/NeMoOnnxSharp/SpeechRecognizer.cs index 96193b6..98986d8 100644 --- a/NeMoOnnxSharp/SpeechRecognizer.cs +++ b/NeMoOnnxSharp/SpeechRecognizer.cs @@ -5,12 +5,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.InteropServices; namespace NeMoOnnxSharp { - public class SpeechRecognizer : IDisposable + public sealed class SpeechRecognizer : IDisposable { public delegate void SpeechStart(long position); public delegate void SpeechEnd(long position, short[] audioSignal, string? transcript); diff --git a/NeMoOnnxSharp/Vocoder.cs b/NeMoOnnxSharp/Vocoder.cs index 8b0dc4e..b33f212 100644 --- a/NeMoOnnxSharp/Vocoder.cs +++ b/NeMoOnnxSharp/Vocoder.cs @@ -6,11 +6,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; namespace NeMoOnnxSharp { - public class Vocoder : IDisposable + public sealed class Vocoder : IDisposable { private readonly InferenceSession _inferSess; private readonly int _nfilt;