本文介绍了我如何使用与SpeechSynthesizer词库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行一些文本到语音,我想在词库文件中指定某些特殊的发音。我已经跑的,它讲一句话,但它确实的的使用给定的词汇,东西似乎被打破。

I'm performing some text-to-speech and I'd like to specify some special pronunciations in a lexicon file. I have ran MSDN's AddLexicon example verbatim, and it speaks the sentence but it does not use the given lexicon, something appears to be broken.

下面是提供的,例如:

using System;
using Microsoft.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      using (SpeechSynthesizer synth = new SpeechSynthesizer())
      {

        // Configure the audio output.
        synth.SetOutputToDefaultAudioDevice();

        PromptBuilder builder = new PromptBuilder();
        builder.AppendText("Gimme the whatchamacallit.");

        // Append the lexicon file.
        synth.AddLexicon(new Uri("c:\\test\\whatchamacallit.pls"), "application/pls+xml");

        // Speak the prompt and play back the output file.
        synth.Speak(builder);
      }

      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }
  }
}

和词库文件:

<lexicon version="1.0"
      xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
        http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"
      alphabet="x-microsoft-ups" xml:lang="en-US">


  <lexeme>
    <grapheme> whatchamacallit </grapheme>
    <phoneme> W S1 AX T CH AX M AX K S2 AA L IH T </phoneme>
  </lexeme>

</lexicon>



控制台打开,文本是口头的,但不使用新的发音。我当然有文件保存到 C:\test\whatchamacallit.pls 为指定的

我'已经开放的和文件位置的尝试变化(例如 @C:\Temp\whatchamacallit.pls @文件:/ //c:\test\whatchamacallit.pls),绝对和相对路径,将其复制到build文件夹等。

I've tried variations of the Uri and file location (e.g. @"C:\Temp\whatchamacallit.pls", @"file:///c:\test\whatchamacallit.pls"), absolute and relative paths, copying it into the build folder, etc.

我跑和文件的未访问即可。如果它是一个目录/文件权限问题(它不是),我仍然会看到访问被拒绝的消息,但是我没有登录在基准以外的所有从我的文字编辑器偶尔之一。我看到访问时,我尝试文件 File.OpenRead

I ran Process Monitor and the file is not accessed. If it were a directory/file permission problem (which it isn't) I would still see the access denied messages, however I log no reference at all except the occasional one from my text editor. I do see the file accessed when I try File.OpenRead.

不幸的是使用时没有错误消息垃圾URI。

Unfortunately there are no error messages when using a garbage Uri.

在进一步的调查,我意识到这个例子是从的,而我使用的在这里。但是从我可以告诉他们,除了一些额外的信息和实例,并都指向同规格相同。难道这仍然是这个问题?

On further investigation I realized this example is from Microsoft.Speech.Synthesis, whereas I'm using System.Speech.Synthesis over here. However from what I can tell they are identical except for some additional info and examples and both point to the same specification. Could this still be the problem?

我核实了项目设置为使用正确的.NET Framework 4。

I verified the project is set to use the proper .NET Framework 4.

我比较从MSDN的例子,从引用的规范

Please refer to this guide on how to install the SDK: http://msdn.microsoft.com/en-us/library/hh362873%28v=office.14%29.aspx

注:


  • 人报告的64位版本导致COM异常(因为库不能正确安装),我在64位的Windows 7证实了这一点机

    • 使用x86版本绕过这个问题

    这篇关于我如何使用与SpeechSynthesizer词库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:30
查看更多