-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d178a9
commit 2cf2439
Showing
13 changed files
with
465 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.31101.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kinect2SampleSpeech", "Kinect2SampleSpeech\Kinect2SampleSpeech.csproj", "{C0661BEF-6F7F-4179-BD18-69381D0CEF77}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Debug|x64.ActiveCfg = Debug|x64 | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Debug|x64.Build.0 = Debug|x64 | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Debug|x64.Deploy.0 = Debug|x64 | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Debug|x86.ActiveCfg = Debug|x64 | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Release|x64.ActiveCfg = Release|x64 | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Release|x64.Build.0 = Release|x64 | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Release|x64.Deploy.0 = Release|x64 | ||
{C0661BEF-6F7F-4179-BD18-69381D0CEF77}.Release|x86.ActiveCfg = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Application | ||
x:Class="Kinect2SampleSpeech.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Kinect2SampleSpeech"> | ||
|
||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.ApplicationModel; | ||
using Windows.ApplicationModel.Activation; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 | ||
|
||
namespace Kinect2SampleSpeech | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
sealed partial class App : Application | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
this.Suspending += OnSuspending; | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the application is launched normally by the end user. Other entry points | ||
/// will be used such as when the application is launched to open a specific file. | ||
/// </summary> | ||
/// <param name="e">Details about the launch request and process.</param> | ||
protected override void OnLaunched(LaunchActivatedEventArgs e) | ||
{ | ||
|
||
#if DEBUG | ||
if (System.Diagnostics.Debugger.IsAttached) | ||
{ | ||
this.DebugSettings.EnableFrameRateCounter = true; | ||
} | ||
#endif | ||
|
||
Frame rootFrame = Window.Current.Content as Frame; | ||
|
||
// Do not repeat app initialization when the Window already has content, | ||
// just ensure that the window is active | ||
if (rootFrame == null) | ||
{ | ||
// Create a Frame to act as the navigation context and navigate to the first page | ||
rootFrame = new Frame(); | ||
// Set the default language | ||
rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; | ||
|
||
rootFrame.NavigationFailed += OnNavigationFailed; | ||
|
||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) | ||
{ | ||
//TODO: Load state from previously suspended application | ||
} | ||
|
||
// Place the frame in the current Window | ||
Window.Current.Content = rootFrame; | ||
} | ||
|
||
if (rootFrame.Content == null) | ||
{ | ||
// When the navigation stack isn't restored navigate to the first page, | ||
// configuring the new page by passing required information as a navigation | ||
// parameter | ||
rootFrame.Navigate(typeof(MainPage), e.Arguments); | ||
} | ||
// Ensure the current window is active | ||
Window.Current.Activate(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when Navigation to a certain page fails | ||
/// </summary> | ||
/// <param name="sender">The Frame which failed navigation</param> | ||
/// <param name="e">Details about the navigation failure</param> | ||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e) | ||
{ | ||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when application execution is being suspended. Application state is saved | ||
/// without knowing whether the application will be terminated or resumed with the contents | ||
/// of memory still intact. | ||
/// </summary> | ||
/// <param name="sender">The source of the suspend request.</param> | ||
/// <param name="e">Details about the suspend request.</param> | ||
private void OnSuspending(object sender, SuspendingEventArgs e) | ||
{ | ||
var deferral = e.SuspendingOperation.GetDeferral(); | ||
//TODO: Save application state and stop any background activity | ||
deferral.Complete(); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+329 Bytes
Kinect2SampleSpeech/Kinect2SampleSpeech/Assets/SmallLogo.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.1 KB
Kinect2SampleSpeech/Kinect2SampleSpeech/Assets/SplashScreen.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+429 Bytes
Kinect2SampleSpeech/Kinect2SampleSpeech/Assets/StoreLogo.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions
92
Kinect2SampleSpeech/Kinect2SampleSpeech/Kinect2SampleSpeech.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{C0661BEF-6F7F-4179-BD18-69381D0CEF77}</ProjectGuid> | ||
<OutputType>AppContainerExe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Kinect2SampleSpeech</RootNamespace> | ||
<AssemblyName>Kinect2SampleSpeech</AssemblyName> | ||
<DefaultLanguage>en-US</DefaultLanguage> | ||
<TargetPlatformVersion>8.1</TargetPlatformVersion> | ||
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<PackageCertificateKeyFile>Kinect2SampleSpeech_TemporaryKey.pfx</PackageCertificateKeyFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_APP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included --> | ||
<SDKReference Include="Bing.Speech, Version=1.1"> | ||
<Name>Bing.Speech</Name> | ||
</SDKReference> | ||
<SDKReference Include="Microsoft.VCLibs, version=12.0"> | ||
<Name>Microsoft Visual C++ 2013 Runtime Package for Windows</Name> | ||
</SDKReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="App.xaml.cs"> | ||
<DependentUpon>App.xaml</DependentUpon> | ||
</Compile> | ||
<Compile Include="MainPage.xaml.cs"> | ||
<DependentUpon>MainPage.xaml</DependentUpon> | ||
</Compile> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AppxManifest Include="Package.appxmanifest"> | ||
<SubType>Designer</SubType> | ||
</AppxManifest> | ||
<None Include="Kinect2SampleSpeech_TemporaryKey.pfx" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Assets\Logo.scale-100.png" /> | ||
<Content Include="Assets\SmallLogo.scale-100.png" /> | ||
<Content Include="Assets\SplashScreen.scale-100.png" /> | ||
<Content Include="Assets\StoreLogo.scale-100.png" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ApplicationDefinition Include="App.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</ApplicationDefinition> | ||
<Page Include="MainPage.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</Page> | ||
</ItemGroup> | ||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' "> | ||
<VisualStudioVersion>12.0</VisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Binary file added
BIN
+2.45 KB
Kinect2SampleSpeech/Kinect2SampleSpeech/Kinect2SampleSpeech_TemporaryKey.pfx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Page | ||
x:Class="Kinect2SampleSpeech.MainPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Kinect2SampleSpeech" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
<Page.Resources> | ||
<Style TargetType="TextBlock"> | ||
<Setter Property="FontSize" Value="15"/> | ||
<Setter Property="Margin" Value="15"/> | ||
</Style> | ||
</Page.Resources> | ||
|
||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center"> | ||
<Button x:Name="StartRecButton" | ||
Margin="20" | ||
Click="StartRecButton_Click">Start Recording</Button> | ||
<TextBlock x:Name="CaptureStateTextBlock"/> | ||
<TextBlock x:Name="VolumeTextBlock" /> | ||
<TextBlock x:Name="IntermediateResultsTextBlock"/> | ||
<TextBlock x:Name="ConfidenceTextBlock"/> | ||
<TextBlock x:Name="FinalResultTextBlock"/> | ||
<TextBlock x:Name="AlternatesTextBlock"/> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
123 changes: 123 additions & 0 deletions
123
Kinect2SampleSpeech/Kinect2SampleSpeech/MainPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
using Bing.Speech; | ||
|
||
namespace Kinect2SampleSpeech | ||
{ | ||
|
||
public sealed partial class MainPage : Page | ||
{ | ||
private SpeechRecognizer speechRec; | ||
|
||
public MainPage() | ||
{ | ||
this.InitializeComponent(); | ||
this.Loaded += MainPage_Loaded; | ||
} | ||
|
||
void MainPage_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
// Apply credentials from the Windows Azure Data Marketplace. | ||
var credentials = new SpeechAuthorizationParameters(); | ||
credentials.ClientId = "YOUR CLIENT ID"; | ||
credentials.ClientSecret = "YOUR CLIENT SECRET"; | ||
|
||
// Initialize the speech recognizer. | ||
speechRec = new SpeechRecognizer("en-US", credentials); | ||
|
||
// Add speech recognition event handlers. | ||
speechRec.AudioCaptureStateChanged += speechRec_AudioCaptureStateChanged; | ||
speechRec.AudioLevelChanged += speechRec_AudioLevelChanged; | ||
speechRec.RecognizerResultReceived += speechRec_RecognizerResultReceived; | ||
} | ||
|
||
void speechRec_RecognizerResultReceived(SpeechRecognizer sender, SpeechRecognitionResultReceivedEventArgs args) | ||
{ | ||
if (args.Text == null) return; | ||
|
||
IntermediateResultsTextBlock.Text = "IntermediateResults: " + args.Text; | ||
|
||
if (args.Text.ToLower().Contains("cancel")) | ||
speechRec.RequestCancelOperation(); | ||
else if (args.Text.ToLower().Contains("stop")) | ||
speechRec.StopListeningAndProcessAudio(); | ||
} | ||
|
||
void speechRec_AudioLevelChanged(SpeechRecognizer sender, SpeechRecognitionAudioLevelChangedEventArgs args) | ||
{ | ||
VolumeTextBlock.Text = "Volume: "+ args.AudioLevel; | ||
} | ||
|
||
void speechRec_AudioCaptureStateChanged(SpeechRecognizer sender, SpeechRecognitionAudioCaptureStateChangedEventArgs args) | ||
{ | ||
CaptureStateTextBlock.Text = "Capture State: " + Enum.GetName(typeof(SpeechRecognizerAudioCaptureState), args.State); | ||
} | ||
|
||
async private void StartRecButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
// Prevent concurrent calls to an async method | ||
StartRecButton.IsEnabled = false; | ||
|
||
// Reset all the text | ||
VolumeTextBlock.Text = ""; | ||
CaptureStateTextBlock.Text = ""; | ||
IntermediateResultsTextBlock.Text = ""; | ||
ConfidenceTextBlock.Text = ""; | ||
FinalResultTextBlock.Text = ""; | ||
AlternatesTextBlock.Text = ""; | ||
|
||
// Use a try block because RecognizeSpeechToTextAsync depends on a web service which can throw exceptions. | ||
try | ||
{ | ||
// Start speech recognition and await the result | ||
// As this is occuring, the RecognizerResultReceived will fire as the user is speaking. | ||
var result = await speechRec.RecognizeSpeechToTextAsync(); | ||
|
||
// Show the TextConfidence. | ||
ConfidenceTextBlock.Text = "Confidence: " + Enum.GetName(typeof(SpeechRecognitionConfidence), result.TextConfidence); | ||
|
||
// Display the text. | ||
if (result.Text != null) | ||
{ | ||
FinalResultTextBlock.Text = result.Text; | ||
} | ||
|
||
// Fill a string with the alternate results. | ||
var alternates = result.GetAlternates(5); | ||
if (alternates.Count > 1) | ||
{ | ||
string s = ""; | ||
for (int i = 1; i < alternates.Count; i++) | ||
{ | ||
s += "\n" + alternates[i].Text ; | ||
} | ||
AlternatesTextBlock.Text = "Alternates: " + s; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
// If there's an exception, show it instead of the Final Result. | ||
if (ex.GetType() != typeof(OperationCanceledException)) | ||
{ | ||
FinalResultTextBlock.Text = string.Format("{0}: {1}", | ||
ex.GetType().ToString(), ex.Message); | ||
} | ||
} | ||
|
||
// Finished recording, allow recording again. | ||
StartRecButton.IsEnabled = true; | ||
} | ||
} | ||
} |
Oops, something went wrong.