main
syneffort 2 years ago
parent 26e8f9ceb4
commit 6079621243
  1. 6
      PacticeSolution/PacticeSolution.sln
  2. 9
      PacticeSolution/Speech/App.xaml
  3. 17
      PacticeSolution/Speech/App.xaml.cs
  4. 10
      PacticeSolution/Speech/AssemblyInfo.cs
  5. 25
      PacticeSolution/Speech/MainWindow.xaml
  6. 81
      PacticeSolution/Speech/MainWindow.xaml.cs
  7. 14
      PacticeSolution/Speech/Speech.csproj

@ -127,6 +127,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkSample", "En
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaPlayer", "MediaPlayer\MediaPlayer.csproj", "{0E7DB4A2-B598-452B-B1B4-CF36685D0D53}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speech", "Speech\Speech.csproj", "{248DDC0C-F8C0-4687-BBC2-71C7C310537E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -381,6 +383,10 @@ Global
{0E7DB4A2-B598-452B-B1B4-CF36685D0D53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E7DB4A2-B598-452B-B1B4-CF36685D0D53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E7DB4A2-B598-452B-B1B4-CF36685D0D53}.Release|Any CPU.Build.0 = Release|Any CPU
{248DDC0C-F8C0-4687-BBC2-71C7C310537E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{248DDC0C-F8C0-4687-BBC2-71C7C310537E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{248DDC0C-F8C0-4687-BBC2-71C7C310537E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{248DDC0C-F8C0-4687-BBC2-71C7C310537E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -0,0 +1,9 @@
<Application x:Class="Speech.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Speech"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Speech
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,25 @@
<Window x:Class="Speech.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Speech"
mc:Ignorable="d"
Title="MainWindow" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button x:Name="speechButton" Grid.Row="0" Content="Speech!" VerticalAlignment="Center" HorizontalAlignment="Center"
Click="speechButton_Click"/>
<StackPanel Grid.Row="1">
<ToggleButton x:Name="recognizeButton" Content="Recognize!" HorizontalAlignment="Center"
Click="recognizeButton_Click"/>
<TextBox x:Name="recognizeBox" Height="50"
IsReadOnly="True"
TextWrapping="Wrap"/>
</StackPanel>
</Grid>
</Window>

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Speech
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private SpeechRecognitionEngine _speechRecognizer;
public MainWindow()
{
InitializeComponent();
InitInstance();
}
private async void InitInstance()
{
_speechRecognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
_speechRecognizer.LoadGrammar(new DictationGrammar());
_speechRecognizer.SpeechRecognized += _speechRecognizer_SpeechRecognized;
_speechRecognizer.SetInputToDefaultAudioDevice();
}
private void speechButton_Click(object sender, RoutedEventArgs e)
{
PromptBuilder promptBuilder = new PromptBuilder();
promptBuilder.AppendText("안녕하세요!");
PromptStyle promptStyle = new PromptStyle();
promptStyle.Volume = PromptVolume.Soft;
promptStyle.Rate = PromptRate.Slow;
promptBuilder.StartStyle(promptStyle);
promptBuilder.AppendText("저는 스피치 신디사이저입니다.");
promptBuilder.EndStyle();
promptBuilder.AppendText("오늘은");
promptBuilder.AppendTextWithHint(DateTime.Now.ToShortDateString(), SayAs.Date);
promptBuilder.AppendText(DateTime.Now.ToString("yyyy년 MM월 dd일 HH시 mm분 ss초 fff밀리세컨드"));
promptBuilder.AppendText("입니다. 이제부터 학습을 시작합시다.");
promptBuilder.AppendText("지금 바로", PromptEmphasis.Strong);
promptBuilder.AppendText("시작 합니다.");
promptBuilder.AppendTextWithHint("WPF", SayAs.SpellOut);
promptBuilder.AppendText("의 세계로!");
SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
speechSynthesizer.Speak(promptBuilder);
}
private void recognizeButton_Click(object sender, RoutedEventArgs e)
{
if (recognizeButton.IsChecked == true)
_speechRecognizer.RecognizeAsync(RecognizeMode.Multiple);
else
_speechRecognizer.RecognizeAsyncStop();
}
private void _speechRecognizer_SpeechRecognized(object? sender, SpeechRecognizedEventArgs e)
{
recognizeBox.AppendText(e.Result.Text);
}
}
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Speech" Version="7.0.0" />
</ItemGroup>
</Project>
Loading…
Cancel
Save