@@ -17,7 +17,7 @@ class Options
17
17
{
18
18
19
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 ; } = 16000 ;
20
+ public int SampleRate { get ; set ; } = 16000 ;
21
21
22
22
[ Option ( "feat-dim" , Required = false , Default = 80 , HelpText = "Dimension of the features used to train the model" ) ]
23
23
public int FeatureDim { get ; set ; } = 80 ;
@@ -31,7 +31,7 @@ class Options
31
31
[ Option ( Required = false , Default = "" , HelpText = "Path to transducer decoder.onnx. Used only for transducer models" ) ]
32
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
35
public string Joiner { get ; set ; } = "" ;
36
36
37
37
[ Option ( "model-type" , Required = false , Default = "" , HelpText = "model type" ) ]
@@ -44,10 +44,22 @@ class Options
44
44
public string WhisperDecoder { get ; set ; } = "" ;
45
45
46
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
49
[ Option ( "whisper-task" , Required = false , Default = "transcribe" , HelpText = "transcribe or translate" ) ]
50
- public string WhisperTask { get ; set ; } = "transcribe" ;
50
+ public string WhisperTask { get ; set ; } = "transcribe" ;
51
+
52
+ [ Option ( "moonshine-preprocessor" , Required = false , Default = "" , HelpText = "Path to preprocess.onnx. Used only for Moonshine models" ) ]
53
+ public string MoonshinePreprocessor { get ; set ; } = "" ;
54
+
55
+ [ Option ( "moonshine-encoder" , Required = false , Default = "" , HelpText = "Path to encode.onnx. Used only for Moonshine models" ) ]
56
+ public string MoonshineEncoder { get ; set ; } = "" ;
57
+
58
+ [ Option ( "moonshine-uncached-decoder" , Required = false , Default = "" , HelpText = "Path to uncached_decode.onnx. Used only for Moonshine models" ) ]
59
+ public string MoonshineUncachedDecoder { get ; set ; } = "" ;
60
+
61
+ [ Option ( "moonshine-cached-decoder" , Required = false , Default = "" , HelpText = "Path to cached_decode.onnx. Used only for Moonshine models" ) ]
62
+ public string MoonshineCachedDecoder { get ; set ; } = "" ;
51
63
52
64
[ Option ( "tdnn-model" , Required = false , Default = "" , HelpText = "Path to tdnn yesno model" ) ]
53
65
public string TdnnModel { get ; set ; } = "" ;
@@ -90,7 +102,7 @@ class Options
90
102
public float HotwordsScore { get ; set ; } = 1.5F ;
91
103
92
104
[ Option ( "files" , Required = true , HelpText = "Audio files for decoding" ) ]
93
- public IEnumerable < string > Files { get ; set ; } = new string [ ] { } ;
105
+ public IEnumerable < string > Files { get ; set ; } = new string [ ] { } ;
94
106
}
95
107
96
108
static void Main ( string [ ] args )
@@ -236,6 +248,13 @@ private static void Run(Options options)
236
248
config . ModelConfig . SenseVoice . Model = options . SenseVoiceModel ;
237
249
config . ModelConfig . SenseVoice . UseInverseTextNormalization = options . SenseVoiceUseItn ;
238
250
}
251
+ else if ( ! String . IsNullOrEmpty ( options . MoonshinePreprocessor ) )
252
+ {
253
+ config . ModelConfig . Moonshine . Preprocessor = options . MoonshinePreprocessor ;
254
+ config . ModelConfig . Moonshine . Encoder = options . MoonshineEncoder ;
255
+ config . ModelConfig . Moonshine . UncachedDecoder = options . MoonshineUncachedDecoder ;
256
+ config . ModelConfig . Moonshine . CachedDecoder = options . MoonshineCachedDecoder ;
257
+ }
239
258
else
240
259
{
241
260
Console . WriteLine ( "Please provide a model" ) ;
@@ -273,10 +292,21 @@ private static void Run(Options options)
273
292
// display results
274
293
for ( int i = 0 ; i != files . Length ; ++ i )
275
294
{
276
- var text = streams [ i ] . Result . Text ;
295
+ var r = streams [ i ] . Result ;
277
296
Console . WriteLine ( "--------------------" ) ;
278
297
Console . WriteLine ( files [ i ] ) ;
279
- Console . WriteLine ( text ) ;
298
+ Console . WriteLine ( "Text: {0}" , r . Text ) ;
299
+ Console . WriteLine ( "Tokens: [{0}]" , string . Join ( ", " , r . Tokens ) ) ;
300
+ if ( r . Timestamps != null && r . Timestamps . Length > 0 ) {
301
+ Console . Write ( "Timestamps: [" ) ;
302
+ var sep = "" ;
303
+ for ( int k = 0 ; k != r . Timestamps . Length ; ++ k )
304
+ {
305
+ Console . Write ( "{0}{1}" , sep , r . Timestamps [ k ] . ToString ( "0.00" ) ) ;
306
+ sep = ", " ;
307
+ }
308
+ Console . WriteLine ( "]" ) ;
309
+ }
280
310
}
281
311
Console . WriteLine ( "--------------------" ) ;
282
312
}
0 commit comments