正在显示
10 个修改的文件
包含
90 行增加
和
79 行删除
| @@ -17,75 +17,74 @@ class OfflineDecodeFiles | @@ -17,75 +17,74 @@ class OfflineDecodeFiles | ||
| 17 | { | 17 | { |
| 18 | 18 | ||
| 19 | [Option("sample-rate", Required = false, Default = 16000, HelpText = "Sample rate of the data used to train the model")] | 19 | [Option("sample-rate", Required = false, Default = 16000, HelpText = "Sample rate of the data used to train the model")] |
| 20 | - public int SampleRate { get; set; } | 20 | + public int SampleRate { get; set; } = 16000; |
| 21 | 21 | ||
| 22 | [Option("feat-dim", Required = false, Default = 80, HelpText = "Dimension of the features used to train the model")] | 22 | [Option("feat-dim", Required = false, Default = 80, HelpText = "Dimension of the features used to train the model")] |
| 23 | - public int FeatureDim { get; set; } | 23 | + public int FeatureDim { get; set; } = 80; |
| 24 | 24 | ||
| 25 | [Option(Required = false, HelpText = "Path to tokens.txt")] | 25 | [Option(Required = false, HelpText = "Path to tokens.txt")] |
| 26 | - public string Tokens { get; set; } | 26 | + public string Tokens { get; set; } = ""; |
| 27 | 27 | ||
| 28 | [Option(Required = false, Default = "", HelpText = "Path to transducer encoder.onnx. Used only for transducer models")] | 28 | [Option(Required = false, Default = "", HelpText = "Path to transducer encoder.onnx. Used only for transducer models")] |
| 29 | - public string Encoder { get; set; } | 29 | + public string Encoder { get; set; } = ""; |
| 30 | 30 | ||
| 31 | [Option(Required = false, Default = "", HelpText = "Path to transducer decoder.onnx. Used only for transducer models")] | 31 | [Option(Required = false, Default = "", HelpText = "Path to transducer decoder.onnx. Used only for transducer models")] |
| 32 | - public string Decoder { get; set; } | 32 | + public string Decoder { get; set; } = ""; |
| 33 | 33 | ||
| 34 | [Option(Required = false, Default = "",HelpText = "Path to transducer joiner.onnx. Used only for transducer models")] | 34 | [Option(Required = false, Default = "",HelpText = "Path to transducer joiner.onnx. Used only for transducer models")] |
| 35 | - public string Joiner { get; set; } | 35 | + public string Joiner { get; set; } = ""; |
| 36 | 36 | ||
| 37 | [Option("model-type", Required = false, Default = "", HelpText = "model type")] | 37 | [Option("model-type", Required = false, Default = "", HelpText = "model type")] |
| 38 | - public string ModelType { get; set; } | 38 | + public string ModelType { get; set; } = ""; |
| 39 | 39 | ||
| 40 | [Option("whisper-encoder", Required = false, Default = "", HelpText = "Path to whisper encoder.onnx. Used only for whisper models")] | 40 | [Option("whisper-encoder", Required = false, Default = "", HelpText = "Path to whisper encoder.onnx. Used only for whisper models")] |
| 41 | - public string WhisperEncoder { get; set; } | 41 | + public string WhisperEncoder { get; set; } = ""; |
| 42 | 42 | ||
| 43 | [Option("whisper-decoder", Required = false, Default = "", HelpText = "Path to whisper decoder.onnx. Used only for whisper models")] | 43 | [Option("whisper-decoder", Required = false, Default = "", HelpText = "Path to whisper decoder.onnx. Used only for whisper models")] |
| 44 | - public string WhisperDecoder { get; set; } | 44 | + public string WhisperDecoder { get; set; } = ""; |
| 45 | 45 | ||
| 46 | [Option("whisper-language", Required = false, Default = "", HelpText = "Language of the input file. Can be empty")] | 46 | [Option("whisper-language", Required = false, Default = "", HelpText = "Language of the input file. Can be empty")] |
| 47 | - public string WhisperLanguage{ get; set; } | 47 | + public string WhisperLanguage{ get; set; } = ""; |
| 48 | 48 | ||
| 49 | [Option("whisper-task", Required = false, Default = "transcribe", HelpText = "transcribe or translate")] | 49 | [Option("whisper-task", Required = false, Default = "transcribe", HelpText = "transcribe or translate")] |
| 50 | - public string WhisperTask{ get; set; } | 50 | + public string WhisperTask{ get; set; } = "transcribe"; |
| 51 | 51 | ||
| 52 | [Option("tdnn-model", Required = false, Default = "", HelpText = "Path to tdnn yesno model")] | 52 | [Option("tdnn-model", Required = false, Default = "", HelpText = "Path to tdnn yesno model")] |
| 53 | - public string TdnnModel { get; set; } | ||
| 54 | - | 53 | + public string TdnnModel { get; set; } = ""; |
| 55 | 54 | ||
| 56 | [Option(Required = false, HelpText = "Path to model.onnx. Used only for paraformer models")] | 55 | [Option(Required = false, HelpText = "Path to model.onnx. Used only for paraformer models")] |
| 57 | - public string Paraformer { get; set; } | 56 | + public string Paraformer { get; set; } = ""; |
| 58 | 57 | ||
| 59 | [Option("nemo-ctc", Required = false, HelpText = "Path to model.onnx. Used only for NeMo CTC models")] | 58 | [Option("nemo-ctc", Required = false, HelpText = "Path to model.onnx. Used only for NeMo CTC models")] |
| 60 | - public string NeMoCtc { get; set; } | 59 | + public string NeMoCtc { get; set; } = ""; |
| 61 | 60 | ||
| 62 | [Option("telespeech-ctc", Required = false, HelpText = "Path to model.onnx. Used only for TeleSpeech CTC models")] | 61 | [Option("telespeech-ctc", Required = false, HelpText = "Path to model.onnx. Used only for TeleSpeech CTC models")] |
| 63 | - public string TeleSpeechCtc { get; set; } | 62 | + public string TeleSpeechCtc { get; set; } = ""; |
| 64 | 63 | ||
| 65 | [Option("num-threads", Required = false, Default = 1, HelpText = "Number of threads for computation")] | 64 | [Option("num-threads", Required = false, Default = 1, HelpText = "Number of threads for computation")] |
| 66 | - public int NumThreads { get; set; } | 65 | + public int NumThreads { get; set; } = 1; |
| 67 | 66 | ||
| 68 | [Option("decoding-method", Required = false, Default = "greedy_search", | 67 | [Option("decoding-method", Required = false, Default = "greedy_search", |
| 69 | HelpText = "Valid decoding methods are: greedy_search, modified_beam_search")] | 68 | HelpText = "Valid decoding methods are: greedy_search, modified_beam_search")] |
| 70 | - public string DecodingMethod { get; set; } | 69 | + public string DecodingMethod { get; set; } = "greedy_search"; |
| 71 | 70 | ||
| 72 | [Option("rule-fsts", Required = false, Default = "", | 71 | [Option("rule-fsts", Required = false, Default = "", |
| 73 | HelpText = "If not empty, path to rule fst for inverse text normalization")] | 72 | HelpText = "If not empty, path to rule fst for inverse text normalization")] |
| 74 | - public string RuleFsts { get; set; } | 73 | + public string RuleFsts { get; set; } = ""; |
| 75 | 74 | ||
| 76 | [Option("max-active-paths", Required = false, Default = 4, | 75 | [Option("max-active-paths", Required = false, Default = 4, |
| 77 | HelpText = @"Used only when --decoding--method is modified_beam_search. | 76 | HelpText = @"Used only when --decoding--method is modified_beam_search. |
| 78 | It specifies number of active paths to keep during the search")] | 77 | It specifies number of active paths to keep during the search")] |
| 79 | - public int MaxActivePaths { get; set; } | 78 | + public int MaxActivePaths { get; set; } = 4; |
| 80 | 79 | ||
| 81 | [Option("hotwords-file", Required = false, Default = "", HelpText = "Path to hotwords.txt")] | 80 | [Option("hotwords-file", Required = false, Default = "", HelpText = "Path to hotwords.txt")] |
| 82 | - public string HotwordsFile { get; set; } | 81 | + public string HotwordsFile { get; set; } = ""; |
| 83 | 82 | ||
| 84 | [Option("hotwords-score", Required = false, Default = 1.5F, HelpText = "hotwords score")] | 83 | [Option("hotwords-score", Required = false, Default = 1.5F, HelpText = "hotwords score")] |
| 85 | - public float HotwordsScore { get; set; } | 84 | + public float HotwordsScore { get; set; } = 1.5F; |
| 86 | 85 | ||
| 87 | [Option("files", Required = true, HelpText = "Audio files for decoding")] | 86 | [Option("files", Required = true, HelpText = "Audio files for decoding")] |
| 88 | - public IEnumerable<string> Files { get; set; } | 87 | + public IEnumerable<string> Files { get; set; } = new string[] {}; |
| 89 | } | 88 | } |
| 90 | 89 | ||
| 91 | static void Main(string[] args) | 90 | static void Main(string[] args) |
| @@ -18,49 +18,49 @@ class OfflineTtsDemo | @@ -18,49 +18,49 @@ class OfflineTtsDemo | ||
| 18 | { | 18 | { |
| 19 | 19 | ||
| 20 | [Option("tts-rule-fsts", Required = false, Default = "", HelpText = "path to rule.fst")] | 20 | [Option("tts-rule-fsts", Required = false, Default = "", HelpText = "path to rule.fst")] |
| 21 | - public string RuleFsts { get; set; } | 21 | + public string RuleFsts { get; set; } = ""; |
| 22 | 22 | ||
| 23 | [Option("tts-rule-fars", Required = false, Default = "", HelpText = "path to rule.far")] | 23 | [Option("tts-rule-fars", Required = false, Default = "", HelpText = "path to rule.far")] |
| 24 | - public string RuleFars { get; set; } | 24 | + public string RuleFars { get; set; } = ""; |
| 25 | 25 | ||
| 26 | [Option("vits-dict-dir", Required = false, Default = "", HelpText = "Path to the directory containing dict for jieba.")] | 26 | [Option("vits-dict-dir", Required = false, Default = "", HelpText = "Path to the directory containing dict for jieba.")] |
| 27 | - public string DictDir { get; set; } | 27 | + public string DictDir { get; set; } = ""; |
| 28 | 28 | ||
| 29 | [Option("vits-data-dir", Required = false, Default = "", HelpText = "Path to the directory containing dict for espeak-ng.")] | 29 | [Option("vits-data-dir", Required = false, Default = "", HelpText = "Path to the directory containing dict for espeak-ng.")] |
| 30 | - public string DataDir { get; set; } | 30 | + public string DataDir { get; set; } = ""; |
| 31 | 31 | ||
| 32 | [Option("vits-length-scale", Required = false, Default = 1, HelpText = "speech speed. Larger->Slower; Smaller->faster")] | 32 | [Option("vits-length-scale", Required = false, Default = 1, HelpText = "speech speed. Larger->Slower; Smaller->faster")] |
| 33 | - public float LengthScale { get; set; } | 33 | + public float LengthScale { get; set; } = 1; |
| 34 | 34 | ||
| 35 | [Option("vits-noise-scale", Required = false, Default = 0.667f, HelpText = "noise_scale for VITS models")] | 35 | [Option("vits-noise-scale", Required = false, Default = 0.667f, HelpText = "noise_scale for VITS models")] |
| 36 | - public float NoiseScale { get; set; } | 36 | + public float NoiseScale { get; set; } = 0.667F; |
| 37 | 37 | ||
| 38 | - [Option("vits-noise-scale-w", Required = false, Default = 0.8f, HelpText = "noise_scale_w for VITS models")] | ||
| 39 | - public float NoiseScaleW { get; set; } | 38 | + [Option("vits-noise-scale-w", Required = false, Default = 0.8F, HelpText = "noise_scale_w for VITS models")] |
| 39 | + public float NoiseScaleW { get; set; } = 0.8F; | ||
| 40 | 40 | ||
| 41 | [Option("vits-lexicon", Required = false, Default = "", HelpText = "Path to lexicon.txt")] | 41 | [Option("vits-lexicon", Required = false, Default = "", HelpText = "Path to lexicon.txt")] |
| 42 | - public string Lexicon { get; set; } | 42 | + public string Lexicon { get; set; } = ""; |
| 43 | 43 | ||
| 44 | [Option("vits-tokens", Required = false, Default = "", HelpText = "Path to tokens.txt")] | 44 | [Option("vits-tokens", Required = false, Default = "", HelpText = "Path to tokens.txt")] |
| 45 | - public string Tokens { get; set; } | 45 | + public string Tokens { get; set; } = ""; |
| 46 | 46 | ||
| 47 | [Option("tts-max-num-sentences", Required = false, Default = 1, HelpText = "Maximum number of sentences that we process at a time.")] | 47 | [Option("tts-max-num-sentences", Required = false, Default = 1, HelpText = "Maximum number of sentences that we process at a time.")] |
| 48 | - public int MaxNumSentences { get; set; } | 48 | + public int MaxNumSentences { get; set; } = 1; |
| 49 | 49 | ||
| 50 | [Option(Required = false, Default = 0, HelpText = "1 to show debug messages.")] | 50 | [Option(Required = false, Default = 0, HelpText = "1 to show debug messages.")] |
| 51 | - public int Debug { get; set; } | 51 | + public int Debug { get; set; } = 0; |
| 52 | 52 | ||
| 53 | [Option("vits-model", Required = true, HelpText = "Path to VITS model")] | 53 | [Option("vits-model", Required = true, HelpText = "Path to VITS model")] |
| 54 | - public string Model { get; set; } | 54 | + public string Model { get; set; } = ""; |
| 55 | 55 | ||
| 56 | [Option("sid", Required = false, Default = 0, HelpText = "Speaker ID")] | 56 | [Option("sid", Required = false, Default = 0, HelpText = "Speaker ID")] |
| 57 | - public int SpeakerId { get; set; } | 57 | + public int SpeakerId { get; set; } = 0; |
| 58 | 58 | ||
| 59 | [Option("text", Required = true, HelpText = "Text to synthesize")] | 59 | [Option("text", Required = true, HelpText = "Text to synthesize")] |
| 60 | - public string Text { get; set; } | 60 | + public string Text { get; set; } = ""; |
| 61 | 61 | ||
| 62 | [Option("output-filename", Required = true, Default = "./generated.wav", HelpText = "Path to save the generated audio")] | 62 | [Option("output-filename", Required = true, Default = "./generated.wav", HelpText = "Path to save the generated audio")] |
| 63 | - public string OutputFilename { get; set; } | 63 | + public string OutputFilename { get; set; } = "./generated.wav"; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static void Main(string[] args) | 66 | static void Main(string[] args) |
| @@ -18,81 +18,80 @@ class OnlineDecodeFiles | @@ -18,81 +18,80 @@ class OnlineDecodeFiles | ||
| 18 | class Options | 18 | class Options |
| 19 | { | 19 | { |
| 20 | [Option(Required = true, HelpText = "Path to tokens.txt")] | 20 | [Option(Required = true, HelpText = "Path to tokens.txt")] |
| 21 | - public string Tokens { get; set; } | 21 | + public string Tokens { get; set; } = ""; |
| 22 | 22 | ||
| 23 | [Option(Required = false, Default = "cpu", HelpText = "Provider, e.g., cpu, coreml")] | 23 | [Option(Required = false, Default = "cpu", HelpText = "Provider, e.g., cpu, coreml")] |
| 24 | - public string Provider { get; set; } | 24 | + public string Provider { get; set; } = ""; |
| 25 | 25 | ||
| 26 | [Option(Required = false, HelpText = "Path to transducer encoder.onnx")] | 26 | [Option(Required = false, HelpText = "Path to transducer encoder.onnx")] |
| 27 | - public string Encoder { get; set; } | 27 | + public string Encoder { get; set; } = ""; |
| 28 | 28 | ||
| 29 | [Option(Required = false, HelpText = "Path to transducer decoder.onnx")] | 29 | [Option(Required = false, HelpText = "Path to transducer decoder.onnx")] |
| 30 | - public string Decoder { get; set; } | 30 | + public string Decoder { get; set; } = ""; |
| 31 | 31 | ||
| 32 | [Option(Required = false, HelpText = "Path to transducer joiner.onnx")] | 32 | [Option(Required = false, HelpText = "Path to transducer joiner.onnx")] |
| 33 | - public string Joiner { get; set; } | 33 | + public string Joiner { get; set; } = ""; |
| 34 | 34 | ||
| 35 | [Option("paraformer-encoder", Required = false, HelpText = "Path to paraformer encoder.onnx")] | 35 | [Option("paraformer-encoder", Required = false, HelpText = "Path to paraformer encoder.onnx")] |
| 36 | - public string ParaformerEncoder { get; set; } | 36 | + public string ParaformerEncoder { get; set; } = ""; |
| 37 | 37 | ||
| 38 | [Option("paraformer-decoder", Required = false, HelpText = "Path to paraformer decoder.onnx")] | 38 | [Option("paraformer-decoder", Required = false, HelpText = "Path to paraformer decoder.onnx")] |
| 39 | - public string ParaformerDecoder { get; set; } | 39 | + public string ParaformerDecoder { get; set; } = ""; |
| 40 | 40 | ||
| 41 | [Option("zipformer2-ctc", Required = false, HelpText = "Path to zipformer2 CTC onnx model")] | 41 | [Option("zipformer2-ctc", Required = false, HelpText = "Path to zipformer2 CTC onnx model")] |
| 42 | - public string Zipformer2Ctc { get; set; } | 42 | + public string Zipformer2Ctc { get; set; } = ""; |
| 43 | 43 | ||
| 44 | [Option("num-threads", Required = false, Default = 1, HelpText = "Number of threads for computation")] | 44 | [Option("num-threads", Required = false, Default = 1, HelpText = "Number of threads for computation")] |
| 45 | - public int NumThreads { get; set; } | 45 | + public int NumThreads { get; set; } = 1; |
| 46 | 46 | ||
| 47 | [Option("decoding-method", Required = false, Default = "greedy_search", | 47 | [Option("decoding-method", Required = false, Default = "greedy_search", |
| 48 | HelpText = "Valid decoding methods are: greedy_search, modified_beam_search")] | 48 | HelpText = "Valid decoding methods are: greedy_search, modified_beam_search")] |
| 49 | - public string DecodingMethod { get; set; } | 49 | + public string DecodingMethod { get; set; } = "greedy_search"; |
| 50 | 50 | ||
| 51 | [Option(Required = false, Default = false, HelpText = "True to show model info during loading")] | 51 | [Option(Required = false, Default = false, HelpText = "True to show model info during loading")] |
| 52 | - public bool Debug { get; set; } | 52 | + public bool Debug { get; set; } = false; |
| 53 | 53 | ||
| 54 | [Option("sample-rate", Required = false, Default = 16000, HelpText = "Sample rate of the data used to train the model")] | 54 | [Option("sample-rate", Required = false, Default = 16000, HelpText = "Sample rate of the data used to train the model")] |
| 55 | - public int SampleRate { get; set; } | 55 | + public int SampleRate { get; set; } = 16000; |
| 56 | 56 | ||
| 57 | [Option("max-active-paths", Required = false, Default = 4, | 57 | [Option("max-active-paths", Required = false, Default = 4, |
| 58 | HelpText = @"Used only when --decoding--method is modified_beam_search. | 58 | HelpText = @"Used only when --decoding--method is modified_beam_search. |
| 59 | It specifies number of active paths to keep during the search")] | 59 | It specifies number of active paths to keep during the search")] |
| 60 | - public int MaxActivePaths { get; set; } | 60 | + public int MaxActivePaths { get; set; } = 4; |
| 61 | 61 | ||
| 62 | [Option("enable-endpoint", Required = false, Default = false, | 62 | [Option("enable-endpoint", Required = false, Default = false, |
| 63 | HelpText = "True to enable endpoint detection.")] | 63 | HelpText = "True to enable endpoint detection.")] |
| 64 | - public bool EnableEndpoint { get; set; } | 64 | + public bool EnableEndpoint { get; set; } = false; |
| 65 | 65 | ||
| 66 | [Option("rule1-min-trailing-silence", Required = false, Default = 2.4F, | 66 | [Option("rule1-min-trailing-silence", Required = false, Default = 2.4F, |
| 67 | HelpText = @"An endpoint is detected if trailing silence in seconds is | 67 | HelpText = @"An endpoint is detected if trailing silence in seconds is |
| 68 | larger than this value even if nothing has been decoded. Used only when --enable-endpoint is true.")] | 68 | larger than this value even if nothing has been decoded. Used only when --enable-endpoint is true.")] |
| 69 | - public float Rule1MinTrailingSilence { get; set; } | 69 | + public float Rule1MinTrailingSilence { get; set; } = 2.4F; |
| 70 | 70 | ||
| 71 | [Option("rule2-min-trailing-silence", Required = false, Default = 1.2F, | 71 | [Option("rule2-min-trailing-silence", Required = false, Default = 1.2F, |
| 72 | HelpText = @"An endpoint is detected if trailing silence in seconds is | 72 | HelpText = @"An endpoint is detected if trailing silence in seconds is |
| 73 | larger than this value after something that is not blank has been decoded. Used | 73 | larger than this value after something that is not blank has been decoded. Used |
| 74 | only when --enable-endpoint is true.")] | 74 | only when --enable-endpoint is true.")] |
| 75 | - public float Rule2MinTrailingSilence { get; set; } | 75 | + public float Rule2MinTrailingSilence { get; set; } = 1.2F; |
| 76 | 76 | ||
| 77 | [Option("rule3-min-utterance-length", Required = false, Default = 20.0F, | 77 | [Option("rule3-min-utterance-length", Required = false, Default = 20.0F, |
| 78 | HelpText = @"An endpoint is detected if the utterance in seconds is | 78 | HelpText = @"An endpoint is detected if the utterance in seconds is |
| 79 | larger than this value. Used only when --enable-endpoint is true.")] | 79 | larger than this value. Used only when --enable-endpoint is true.")] |
| 80 | - public float Rule3MinUtteranceLength { get; set; } | 80 | + public float Rule3MinUtteranceLength { get; set; } = 20.0F; |
| 81 | 81 | ||
| 82 | [Option("hotwords-file", Required = false, Default = "", HelpText = "Path to hotwords.txt")] | 82 | [Option("hotwords-file", Required = false, Default = "", HelpText = "Path to hotwords.txt")] |
| 83 | - public string HotwordsFile { get; set; } | 83 | + public string HotwordsFile { get; set; } = ""; |
| 84 | 84 | ||
| 85 | [Option("hotwords-score", Required = false, Default = 1.5F, HelpText = "hotwords score")] | 85 | [Option("hotwords-score", Required = false, Default = 1.5F, HelpText = "hotwords score")] |
| 86 | - public float HotwordsScore { get; set; } | 86 | + public float HotwordsScore { get; set; } = 1.5F; |
| 87 | 87 | ||
| 88 | [Option("rule-fsts", Required = false, Default = "", | 88 | [Option("rule-fsts", Required = false, Default = "", |
| 89 | HelpText = "If not empty, path to rule fst for inverse text normalization")] | 89 | HelpText = "If not empty, path to rule fst for inverse text normalization")] |
| 90 | - public string RuleFsts { get; set; } | 90 | + public string RuleFsts { get; set; } = ""; |
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | [Option("files", Required = true, HelpText = "Audio files for decoding")] | 93 | [Option("files", Required = true, HelpText = "Audio files for decoding")] |
| 94 | - public IEnumerable<string> Files { get; set; } | ||
| 95 | - | 94 | + public IEnumerable<string> Files { get; set; } = new string[] {}; |
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | static void Main(string[] args) | 97 | static void Main(string[] args) |
| @@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
| 2 | 2 | ||
| 3 | using System; | 3 | using System; |
| 4 | using System.Collections.Generic; | 4 | using System.Collections.Generic; |
| 5 | -using System.Linq; | ||
| 6 | using System.Runtime.InteropServices; | 5 | using System.Runtime.InteropServices; |
| 7 | 6 | ||
| 8 | namespace SherpaOnnx | 7 | namespace SherpaOnnx |
| @@ -29,7 +28,14 @@ namespace SherpaOnnx | @@ -29,7 +28,14 @@ namespace SherpaOnnx | ||
| 29 | // The caller should ensure all passed streams are ready for decoding. | 28 | // The caller should ensure all passed streams are ready for decoding. |
| 30 | public void Decode(IEnumerable<OfflineStream> streams) | 29 | public void Decode(IEnumerable<OfflineStream> streams) |
| 31 | { | 30 | { |
| 32 | - IntPtr[] ptrs = streams.Select(s => s.Handle).ToArray(); | 31 | + // TargetFramework=net20 does not support System.Linq |
| 32 | + // IntPtr[] ptrs = streams.Select(s => s.Handle).ToArray(); | ||
| 33 | + List<IntPtr> list = new List<IntPtr>(); | ||
| 34 | + foreach (OfflineStream s in streams) | ||
| 35 | + { | ||
| 36 | + list.Add(s.Handle); | ||
| 37 | + } | ||
| 38 | + IntPtr[] ptrs = list.ToArray(); | ||
| 33 | Decode(_handle.Handle, ptrs, ptrs.Length); | 39 | Decode(_handle.Handle, ptrs, ptrs.Length); |
| 34 | } | 40 | } |
| 35 | 41 |
| @@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
| 3 | /// Copyright (c) 2024.5 by 东风破 | 3 | /// Copyright (c) 2024.5 by 东风破 |
| 4 | using System; | 4 | using System; |
| 5 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
| 6 | -using System.Linq; | ||
| 7 | using System.Runtime.InteropServices; | 6 | using System.Runtime.InteropServices; |
| 8 | 7 | ||
| 9 | namespace SherpaOnnx | 8 | namespace SherpaOnnx |
| @@ -49,7 +48,15 @@ namespace SherpaOnnx | @@ -49,7 +48,15 @@ namespace SherpaOnnx | ||
| 49 | // The caller should ensure all passed streams are ready for decoding. | 48 | // The caller should ensure all passed streams are ready for decoding. |
| 50 | public void Decode(IEnumerable<OnlineStream> streams) | 49 | public void Decode(IEnumerable<OnlineStream> streams) |
| 51 | { | 50 | { |
| 52 | - IntPtr[] ptrs = streams.Select(s => s.Handle).ToArray(); | 51 | + // TargetFramework=net20 does not support System.Linq |
| 52 | + // IntPtr[] ptrs = streams.Select(s => s.Handle).ToArray(); | ||
| 53 | + List<IntPtr> list = new List<IntPtr>(); | ||
| 54 | + foreach (OnlineStream s in streams) | ||
| 55 | + { | ||
| 56 | + list.Add(s.Handle); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + IntPtr[] ptrs = list.ToArray(); | ||
| 53 | Decode(_handle.Handle, ptrs, ptrs.Length); | 60 | Decode(_handle.Handle, ptrs, ptrs.Length); |
| 54 | } | 61 | } |
| 55 | 62 |
| @@ -38,7 +38,7 @@ macos_arm64_wheel=$src_dir/$macos_arm64_wheel_filename | @@ -38,7 +38,7 @@ macos_arm64_wheel=$src_dir/$macos_arm64_wheel_filename | ||
| 38 | windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl | 38 | windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl |
| 39 | windows_x64_wheel=$src_dir/$windows_x64_wheel_filename | 39 | windows_x64_wheel=$src_dir/$windows_x64_wheel_filename |
| 40 | 40 | ||
| 41 | -windows_x86_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win32.whl | 41 | +windows_x86_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86.tar.bz2 |
| 42 | windows_x86_wheel=$src_dir/$windows_x86_wheel_filename | 42 | windows_x86_wheel=$src_dir/$windows_x86_wheel_filename |
| 43 | 43 | ||
| 44 | windows_arm64_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2 | 44 | windows_arm64_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2 |
| @@ -138,10 +138,10 @@ if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then | @@ -138,10 +138,10 @@ if [ ! -f $src_dir/windows-x86/sherpa-onnx-core.dll ]; then | ||
| 138 | if [ -f $windows_x86_wheel ]; then | 138 | if [ -f $windows_x86_wheel ]; then |
| 139 | cp -v $windows_x86_wheel . | 139 | cp -v $windows_x86_wheel . |
| 140 | else | 140 | else |
| 141 | - curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$windows_x86_wheel_filename | 141 | + curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-libs/resolve/main/windows-for-dotnet/$windows_x86_wheel_filename |
| 142 | fi | 142 | fi |
| 143 | - unzip $windows_x86_wheel_filename | ||
| 144 | - cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll ../ | 143 | + tar xvf $windows_x86_wheel_filename |
| 144 | + cp -v sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86/*dll ../ | ||
| 145 | cd .. | 145 | cd .. |
| 146 | 146 | ||
| 147 | rm -rf wheel | 147 | rm -rf wheel |
| @@ -159,7 +159,7 @@ if [ ! -f $src_dir/windows-arm64/sherpa-onnx-core.dll ]; then | @@ -159,7 +159,7 @@ if [ ! -f $src_dir/windows-arm64/sherpa-onnx-core.dll ]; then | ||
| 159 | else | 159 | else |
| 160 | curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-libs/resolve/main/windows-for-dotnet/$windows_arm64_wheel_filename | 160 | curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-libs/resolve/main/windows-for-dotnet/$windows_arm64_wheel_filename |
| 161 | fi | 161 | fi |
| 162 | - unzip $windows_arm64_wheel_filename | 162 | + tar xvf $windows_arm64_wheel_filename |
| 163 | cp -v sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64/*dll ../ | 163 | cp -v sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64/*dll ../ |
| 164 | cd .. | 164 | cd .. |
| 165 | 165 |
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | <PackageReadmeFile>README.md</PackageReadmeFile> | 4 | <PackageReadmeFile>README.md</PackageReadmeFile> |
| 5 | <OutputType>Library</OutputType> | 5 | <OutputType>Library</OutputType> |
| 6 | <LangVersion>10.0</LangVersion> | 6 | <LangVersion>10.0</LangVersion> |
| 7 | - <TargetFrameworks>netstandard2.0</TargetFrameworks> | 7 | + <TargetFrameworks>net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks> |
| 8 | <RuntimeIdentifiers>linux-x64;osx-x64;osx-arm64;win-x64;win-x86;win-arm64</RuntimeIdentifiers> | 8 | <RuntimeIdentifiers>linux-x64;osx-x64;osx-arm64;win-x64;win-x86;win-arm64</RuntimeIdentifiers> |
| 9 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | 9 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
| 10 | <AssemblyName>sherpa-onnx</AssemblyName> | 10 | <AssemblyName>sherpa-onnx</AssemblyName> |
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | 3 | <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> |
| 4 | <PackageReadmeFile>README.md</PackageReadmeFile> | 4 | <PackageReadmeFile>README.md</PackageReadmeFile> |
| 5 | <OutputType>Library</OutputType> | 5 | <OutputType>Library</OutputType> |
| 6 | - <TargetFrameworks>netstandard2.0</TargetFrameworks> | 6 | + <TargetFrameworks>net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks> |
| 7 | <RuntimeIdentifier>{{ dotnet_rid }}</RuntimeIdentifier> | 7 | <RuntimeIdentifier>{{ dotnet_rid }}</RuntimeIdentifier> |
| 8 | <AssemblyName>sherpa-onnx</AssemblyName> | 8 | <AssemblyName>sherpa-onnx</AssemblyName> |
| 9 | <Version>{{ version }}</Version> | 9 | <Version>{{ version }}</Version> |
| @@ -171,7 +171,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | @@ -171,7 +171,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | ||
| 171 | joiner = "$modelDir/joiner-epoch-30-avg-4.onnx", | 171 | joiner = "$modelDir/joiner-epoch-30-avg-4.onnx", |
| 172 | ), | 172 | ), |
| 173 | tokens = "$modelDir/tokens.txt", | 173 | tokens = "$modelDir/tokens.txt", |
| 174 | - modelType = "zipformer", | 174 | + modelType = "transducer", |
| 175 | ) | 175 | ) |
| 176 | } | 176 | } |
| 177 | 177 | ||
| @@ -209,7 +209,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | @@ -209,7 +209,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | ||
| 209 | joiner = "$modelDir/joiner-epoch-12-avg-4.int8.onnx", | 209 | joiner = "$modelDir/joiner-epoch-12-avg-4.int8.onnx", |
| 210 | ), | 210 | ), |
| 211 | tokens = "$modelDir/tokens.txt", | 211 | tokens = "$modelDir/tokens.txt", |
| 212 | - modelType = "zipformer", | 212 | + modelType = "transducer", |
| 213 | ) | 213 | ) |
| 214 | } | 214 | } |
| 215 | 215 | ||
| @@ -222,7 +222,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | @@ -222,7 +222,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | ||
| 222 | joiner = "$modelDir/joiner-epoch-20-avg-1.int8.onnx", | 222 | joiner = "$modelDir/joiner-epoch-20-avg-1.int8.onnx", |
| 223 | ), | 223 | ), |
| 224 | tokens = "$modelDir/tokens.txt", | 224 | tokens = "$modelDir/tokens.txt", |
| 225 | - modelType = "zipformer2", | 225 | + modelType = "transducer", |
| 226 | ) | 226 | ) |
| 227 | } | 227 | } |
| 228 | 228 | ||
| @@ -281,7 +281,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | @@ -281,7 +281,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | ||
| 281 | return OfflineModelConfig( | 281 | return OfflineModelConfig( |
| 282 | teleSpeech = "$modelDir/model.int8.onnx", | 282 | teleSpeech = "$modelDir/model.int8.onnx", |
| 283 | tokens = "$modelDir/tokens.txt", | 283 | tokens = "$modelDir/tokens.txt", |
| 284 | - modelType = "tele_speech", | 284 | + modelType = "telespeech_ctc", |
| 285 | ) | 285 | ) |
| 286 | } | 286 | } |
| 287 | 287 | ||
| @@ -294,7 +294,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | @@ -294,7 +294,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | ||
| 294 | joiner = "$modelDir/joiner-epoch-12-avg-5.int8.onnx", | 294 | joiner = "$modelDir/joiner-epoch-12-avg-5.int8.onnx", |
| 295 | ), | 295 | ), |
| 296 | tokens = "$modelDir/tokens.txt", | 296 | tokens = "$modelDir/tokens.txt", |
| 297 | - modelType = "zipformer2", | 297 | + modelType = "transducer", |
| 298 | ) | 298 | ) |
| 299 | } | 299 | } |
| 300 | 300 | ||
| @@ -307,7 +307,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | @@ -307,7 +307,7 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { | ||
| 307 | joiner = "$modelDir/joiner-epoch-99-avg-1.int8.onnx", | 307 | joiner = "$modelDir/joiner-epoch-99-avg-1.int8.onnx", |
| 308 | ), | 308 | ), |
| 309 | tokens = "$modelDir/tokens.txt", | 309 | tokens = "$modelDir/tokens.txt", |
| 310 | - modelType = "zipformer2", | 310 | + modelType = "transducer", |
| 311 | ) | 311 | ) |
| 312 | } | 312 | } |
| 313 | } | 313 | } |
-
请 注册 或 登录 后发表评论