问题得到改善:演讲课上的事件只会发出某些声音 [英] question improved: speech class events only fires with certain voices

查看:98
本文介绍了问题得到改善:演讲课上的事件只会发出某些声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统中安装了5种不同的声音

Alberto16
奥黛丽16
IVONA艾米
微软山姆
VM Kate

当我运行以下测试应用程序时,Alberto16和Audrey16都不会触发"speechinprogress"事件.其他所有声音触发事件.这可能是语音API中的错误.

I have 5 different voices installed in my system

Alberto16
Audrey16
IVONA Amy
Microsoft Sam
VM Kate

when I run the following test app both Alberto16 and Audrey16 do not fire the "speechinprogress" event. All the other voices fire the event. Could this be a bug in the speech API.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Synthesis;

namespace EventhandlerProblem
{
    public partial class Form1 : Form
    {

        SpeechSynthesizer synth = new SpeechSynthesizer();
        PromptBuilder pb = new PromptBuilder();
        String[] installedVoices = new String[10];
        
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            //gets all installed  voices and displays them in the listbox
            foreach (InstalledVoice voice in synth.GetInstalledVoices())
            {
                comboBox1.Items.Add(voice.VoiceInfo.Name);
                System.Console.WriteLine(voice.VoiceInfo.Name);
            }

            synth.SpeakProgress += new EventHandler<speakprogresseventargs>(synth_SpeakProgress);
        }

        void synth_SpeakProgress(object sender, SpeakProgressEventArgs e)
        {
            System.Console.WriteLine("speech in progress");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pb.ClearContent();
            pb.AppendText("This is a test");
            synth.Speak(pb);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            synth.SelectVoice(comboBox1.Text);
        }
    }
}

推荐答案

Thx Dave!

我已经安装了5种声音来回尝试.行为很明显.只有那两个声音不起作用.我刚刚在系统中添加了一些事件处理程序和一个声音.现在有更多的混乱行为.所有声音都引发了语音启动"事件.没有声音触发语音结束"事件. 16位语音和西班牙语语音都没有在进行中的事件"中触发语音,这的确看起来像语音API中的错误.这是我添加到上一个项目中的代码.

Thx Dave!

I have tried back and forth with the 5 voices installed. the behavior is clear. Only those 2 voices don''t work. I have just added some more eventhandlers and one more voice to my system. Now there is even more chaotic behavior. All voices fire the "speech started" event. No voice fires the "speech ended" event. None of the 16bit voices and the spanish voices fire the speech in "progress event" it really looks like a bug in the speech API. here is the code I added to the previous project.

synth.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(synth_SpeakCompleted);
    synth.SpeakStarted += new EventHandler<SpeakStartedEventArgs>(synth_SpeakStarted);
    synth.BookmarkReached += new EventHandler<BookmarkReachedEventArgs>(synth_BookmarkReached);
}

void synth_BookmarkReached(object sender, BookmarkReachedEventArgs e)
{
    System.Console.WriteLine("bookmark reached");
}

void synth_SpeakStarted(object sender, SpeakStartedEventArgs e)
{
    System.Console.WriteLine("speech has started");
}

void synth_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
{
    System.Console.WriteLine("speech is completed");
}


这篇关于问题得到改善:演讲课上的事件只会发出某些声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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