diff --git a/examples/net_framework/DeepSpeechWPF/App.xaml.cs b/examples/net_framework/DeepSpeechWPF/App.xaml.cs index 88f39643..67dad8ed 100644 --- a/examples/net_framework/DeepSpeechWPF/App.xaml.cs +++ b/examples/net_framework/DeepSpeechWPF/App.xaml.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; +using CommonServiceLocator; +using DeepSpeech.WPF.ViewModels; +using DeepSpeechClient.Interfaces; +using GalaSoft.MvvmLight.Ioc; using System.Windows; namespace DeepSpeechWPF @@ -13,5 +11,34 @@ namespace DeepSpeechWPF /// public partial class App : Application { + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + const int BEAM_WIDTH = 500; + + //Register instance of DeepSpeech + DeepSpeechClient.DeepSpeech deepSpeechClient = new DeepSpeechClient.DeepSpeech(); + try + { + deepSpeechClient.CreateModel("output_graph.pbmm", BEAM_WIDTH); + } + catch (System.Exception ex) + { + MessageBox.Show(ex.Message); + Current.Shutdown(); + } + + SimpleIoc.Default.Register(() => deepSpeechClient); + SimpleIoc.Default.Register(); + } + + protected override void OnExit(ExitEventArgs e) + { + base.OnExit(e); + //Dispose instance of DeepSpeech + ServiceLocator.Current.GetInstance()?.Dispose(); + } } } diff --git a/examples/net_framework/DeepSpeechWPF/DeepSpeech.WPF.csproj b/examples/net_framework/DeepSpeechWPF/DeepSpeech.WPF.csproj index db4d56af..532c1a9a 100644 --- a/examples/net_framework/DeepSpeechWPF/DeepSpeech.WPF.csproj +++ b/examples/net_framework/DeepSpeechWPF/DeepSpeech.WPF.csproj @@ -40,15 +40,36 @@ true + + packages\AsyncAwaitBestPractices.3.1.0\lib\netstandard1.0\AsyncAwaitBestPractices.dll + + + packages\AsyncAwaitBestPractices.MVVM.3.1.0\lib\netstandard1.0\AsyncAwaitBestPractices.MVVM.dll + + + packages\CommonServiceLocator.2.0.2\lib\net45\CommonServiceLocator.dll + packages\CSCore.1.2.1.2\lib\net35-client\CSCore.dll + + packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + + + packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + packages\NAudio.1.9.0\lib\net35\NAudio.dll + + packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + @@ -67,6 +88,7 @@ MSBuild:Compile Designer + MSBuild:Compile Designer @@ -75,6 +97,7 @@ App.xaml Code + MainWindow.xaml Code diff --git a/examples/net_framework/DeepSpeechWPF/MainWindow.xaml b/examples/net_framework/DeepSpeechWPF/MainWindow.xaml index 4366a821..00f91fd7 100644 --- a/examples/net_framework/DeepSpeechWPF/MainWindow.xaml +++ b/examples/net_framework/DeepSpeechWPF/MainWindow.xaml @@ -16,11 +16,10 @@