system.speech dll出现问题

问题描述:

大家好,

我正在创建一个应用程序,我想在其中输入文本,然后单击按钮,它会说出我在文本框中输入的内容,..

它正在工作,但听起来只不过是普拉赫-普拉赫...

以下是代码:-

hello all,

I am creating a application in which i want to enter text in a text box and after that by clicking on button it will speak out what i have entered in textbox,..

it is working but it only sounds like plah-plah...

following is the code:-

using System;
using System.Collections.Generic;
using System.Text;
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.Shapes;
using System.Speech.Synthesis;

namespace ItSpeaks
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private SpeechSynthesizer speech;
        public MainWindow()
        {
            this.InitializeComponent();
            speech= new SpeechSynthesizer();

            // Insert code required on object creation below this point.
        }

        private void Speak(object sender, System.Windows.RoutedEventArgs e)
        {
            speech.SpeakAsync(textToSpeak.Text);
            speech.Volume = 100;
            speech.Rate = -2;
            // TODO: Add event handler implementation here.
        }
    }
}

之所以会发生这种情况,是因为输出的语音语言与您的文本不匹配.尝试使用其他输出声音.您可以通过以下方式获取所有已安装语音的列表:
This probably happens since the output voice language does not match your text. Try it out with a different output voice. Here is how you can get a list of all installed voices:
System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Synthesis.InstalledVoice> tmp = speech.GetInstalledVoices();
foreach (object MyVoice in tmp)
{
  comboBox1.Items.Add((MyVoice as System.Speech.Synthesis.InstalledVoice).VoiceInfo.Name);
}


如果没有语音匹配,则可能要安装新的语音.


If no voice matches, you may want to install a new voice.