2. Tool: Visual Studio 2012
3. Coding
WPF :
<Window x:Class="WPFGoogleTTS.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" >
<StackPanel>
<TextBox Name="tb1" Height="30" Width="300" >這是一個測試</TextBox>
<Button Name="btn1" Click="btn1_Click" Width="150" Height="50" ></Button>
<MediaElement Name="med1" Width="20" Height="20" LoadedBehavior="Manual" >
</MediaElement>
</StackPanel>
</Window>
C# :
namespace WPFGoogleTTS
{
/// <summary>
/// MainWindow.xaml 的互動邏輯
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btn1_Click(object sender, RoutedEventArgs e)
{
var chinese = "這是一個測試。";
string pathx = "http://translate.google.com/translate_tts?ie=UTF-8&tl=zh-TW&q=" + tb1.Text ;
Uri u = new Uri(pathx, UriKind.RelativeOrAbsolute);
med1.Source = u;
med1.Play();
}
}
}
沒有留言:
張貼留言