2013-07-10 24 views
3

我只是嘗試運行簡單的微軟示例文本到語音使用Microsoft.Speech.dll;Microsoft.Speech.Synthesis不適用於文本到語音但System.Speech.Synthesis works.Why?

using System; 
using Microsoft.Speech.Synthesis; 

namespace TTS 
{ 
    class Program 
    { 
     public static void Main(string[] args) 
     { 
      Console.WriteLine("Testing TTS!"); 

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

       // Output information about all of the installed voices. 
       Console.WriteLine("Installed voices -"); 
       foreach (InstalledVoice voice in synth.GetInstalledVoices()) 
       { 
        VoiceInfo info = voice.VoiceInfo; 
        Console.WriteLine(" Voice Name: " + info.Name); 
       } 

       // Select the US English voice. 
       synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)"); 

       // Build a prompt. 
       PromptBuilder builder = new PromptBuilder(); 
       builder.AppendText("That is a big pizza!"); 

       // Speak the prompt. 
       synth.Speak(builder); 
      } 

      Console.Write("Press any key to continue . . . "); 
      Console.ReadKey(true); 
     } 
    } 
} 

雖然我有權利的聲音,它不發出任何聲音。沒有文本到語音(TTS)語音。

enter image description here

當我使用Microsoft System.Speech.dll然後我能聽到的聲音。所以沒有健全的問題。

using System; 
using System.Speech.Synthesis; 

namespace TTS 
{ 
    class Program 
    { 
     public static void Main(string[] args) 
     { 
      Console.WriteLine("Testing TTS!"); 

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

       // Output information about all of the installed voices. 
       Console.WriteLine("Installed voices -"); 
       foreach (InstalledVoice voice in synth.GetInstalledVoices()) 
       { 
        VoiceInfo info = voice.VoiceInfo; 
        Console.WriteLine(" Voice Name: " + info.Name); 
       } 

       // Build a prompt. 
       PromptBuilder builder = new PromptBuilder(); 
       builder.AppendText("That is a big pizza!"); 

       // Speak the prompt. 
       synth.Speak(builder); 
      } 

      Console.Write("Press any key to continue . . . "); 
      Console.ReadKey(true); 
     } 
    } 
} 

enter image description here

不久

爲什麼我聽不到任何聲音或使用Microsoft.Speech與 微軟語音平臺使文本到語音轉換(TTS)?我應該做一些 額外配置?

回答

4

因爲您正在使用兩個不同的TTS引擎。 Microsoft.Speech使用服務器TTS語音; System.Speech使用桌面TTS語音。參見討論here

Windows Vista及以上版本默認已註冊桌面TTS語音,但沒有服務器TTS語音。當您安裝Server Speech Platform Runtime時,我相信您必須先完成加載Microsoft.Speech.dll,您應該可以選擇安裝某些服務器TTS語音。

+0

我安裝了服務器tts的聲音......和我的Microsoft.Speech測試程序列出它們。我看到了無聲的聲音,並在Windows註冊表中檢查它們。 –

+1

你有沒有調用[SetOutputToDefaultAudioDevice](http://msdn.microsoft.com/en-us/library/lync/microsoft.speech.synthesis.speechsynthesizer.setoutputtodefaultaudiodevice(v = office.13).aspx)?默認情況下,Microsoft.Speech引擎不會發生這種情況,而System.Speech引擎會引發這種情況。 –

0

在Visual Studio中選擇項目,然後選擇添加引用,旁邊System.Speech

在程序中使用不作爲system.speech以及一個然後選擇複選框。

適合我。

相關問題