Are the SpeakProgressEventArgs of the SpeechSynthesizer inaccurate?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 17:41:20

the audioPosition depends on the selected voice of the speech synthesizer. For some Microsoft voices, such as Anna, Zira, David, Hazel, as I have experienced, the supported audio format is a 16000Hz PCM. So the following solution can correct the auido position:

var format = 
new System.Speech.AudioFormat.SpeechAudioFormatInfo(EncodingFormat.Pcm, 
                                                    16000, 16, 1, 32000, 2, null);
synthesizer.SetOutputToWaveFile("Test.wav", format);

if you note, the default sample rate of the SetOutputToWaveFile is 22050, and the ratio of the correct time (15.69) to the time shown by AudipPosition (20.25) is about 0.77. If you multiply this ratio by 22050 you get about 16000, which is the correct sample rate.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!