Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 具有持续时间属性的SpeechSynthesizer?_C#_Speech Synthesis - Fatal编程技术网

C# 具有持续时间属性的SpeechSynthesizer?

C# 具有持续时间属性的SpeechSynthesizer?,c#,speech-synthesis,C#,Speech Synthesis,我需要一个具有可设置的持续时间属性的语音合成器,以指定说出文本所需的时间。System.Speech.Synthesis.SpeechSynthesis类只有Rate属性 有一个System.Speech.Synthesis.TtsEngine命名空间,它有一个具有可设置属性的韵律类。但是我找不到任何关于如何使用TtsEngine或者如何将这个属性应用到SpeechSynthesizer类的例子(如果可能的话)。还是有其他语音合成库我应该研究一下?多亏了第一次回复中的提示,我想我找到了答案 在第

我需要一个具有可设置的持续时间属性的语音合成器,以指定说出文本所需的时间。System.Speech.Synthesis.SpeechSynthesis类只有Rate属性


有一个System.Speech.Synthesis.TtsEngine命名空间,它有一个具有可设置属性的韵律类。但是我找不到任何关于如何使用TtsEngine或者如何将这个属性应用到SpeechSynthesizer类的例子(如果可能的话)。还是有其他语音合成库我应该研究一下?

多亏了第一次回复中的提示,我想我找到了答案

在第一次通话中,整个讲话都很慢,持续了10秒钟


对于第二个呼叫,“american 123”与第一个呼叫一样缓慢且拖长,但后面的部分以正常速度说话,给出的总持续时间<期望值。因此,我必须将数字转换为单词,以获得一致的性能。(或者可能有一个属性会影响合成器处理数字的方式,从而更正此错误。如果我找到任何内容,将进行更新。)

是否要获取说某个文本所需的持续时间?(例如,说“Hello World”需要多长时间?)或者您想设置一些文本的说话持续时间吗?(即,我希望合成器在1秒内说出“hello world”(你好世界)道歉和感谢。我需要一个可设置的持续时间属性,如prosody类中所示。
    using System.Speech.Synthesis;
    
    SpeechSynthesizer synthesizer = new SpeechSynthesizer();

    void speak_utterance(string utterance_text, int duration_millisec = 0) {

        if (duration_millisec <= 0) {
            synthesizer.Speak(utterance_text);
        }
        else {
            PromptBuilder builder = new PromptBuilder();
            builder.AppendSsmlMarkup("<prosody duration='" + duration_millisec.ToString() + "ms'>" + utterance_text + "</prosody>");
            synthesizer.Speak(builder);
        }
    }
    string clearance0 = "american one twenty three cleared to land runway one left"
    string clearance1= "american 123 cleared to land runway one left"

    speak_utterance(clearance0, 10000);
    speak_utterance(clearance1, 10000);