system.speech dll出现问题 [英] problem with system.speech dll

查看:446
本文介绍了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.


这篇关于system.speech dll出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆