我目前正在研究一種應用程序,需要傳輸編碼爲特定音頻格式的語音。問題SpeechSynthesizer.SetOutputToAudioStream音頻格式問題
System.Speech.AudioFormat.SpeechAudioFormatInfo synthFormat =
new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm,
8000, 16, 1, 16000, 2, null);
這指出該音頻是在PCM格式,每秒8000個樣本,每個樣本16位,單聲道,每秒16000個平均字節的2
塊對齊當我試圖執行下面的代碼沒有寫入我的MemoryStream實例;然而,當我從每秒8000個採樣改變到11025時,音頻數據被成功寫入。
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
waveStream = new MemoryStream();
PromptBuilder pbuilder = new PromptBuilder();
PromptStyle pStyle = new PromptStyle();
pStyle.Emphasis = PromptEmphasis.None;
pStyle.Rate = PromptRate.Fast;
pStyle.Volume = PromptVolume.ExtraLoud;
pbuilder.StartStyle(pStyle);
pbuilder.StartParagraph();
pbuilder.StartVoice(VoiceGender.Male, VoiceAge.Teen, 2);
pbuilder.StartSentence();
pbuilder.AppendText("This is some text.");
pbuilder.EndSentence();
pbuilder.EndVoice();
pbuilder.EndParagraph();
pbuilder.EndStyle();
synthesizer.SetOutputToAudioStream(waveStream, synthFormat);
synthesizer.Speak(pbuilder);
synthesizer.SetOutputToNull();
有沒有使用的8000的採樣率時,我無法找到有關SetOutputToAudioStream任何文檔中有用,爲什麼它成功以每秒11025個樣本,而不是8000我有一個記錄的異常或錯誤解決方法包括使用一些聲音編輯工具生成並轉換爲正確採樣率的wav文件,但是如果可以的話,我想從應用程序內部生成音頻。
的興趣特別一點是,SpeechRecognitionEngine接受音頻格式,併成功地認識到我的合成波文件中的講話...
更新:最近發現,這種音頻格式成功對某些安裝的聲音,但失敗爲他人。它特別針對LH Michael和LH Michelle而失敗,並且PromptBuilder中定義的某些語音設置的故障會有所不同。
對不起,如果我打斷你,似乎你是音頻材料的專家,我有[這個問題](http://stackoverflow.com/q/33932390/2651073)這讓我感到困惑,你能幫我那? – Ahmad 2015-12-09 19:35:40