java web jacob 调用微软语音库获取音频流
发布网友
发布时间:2022-04-20 05:47
我来回答
共1个回答
热心网友
时间:2023-08-30 14:19
生成 wav,然后网页中嵌入
请参考生成wave的C#代码
/// <summary>
/// 输出WAV
/// </summary>
/// <param name="path">保存路径</param>
/// <param name="str">要转换的文本内容</param>
/// <returns></returns>
public bool WreiteToWAV(string path,string str,SpeechAudioFormatType SpAudioType)
{
SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite;
SpFileStream SpFileStream = new SpFileStream();
SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
SpAudioFormat SpAudio = new DotNetSpeech.SpAudioFormat();
SpAudio.Type = SpAudioType;
SpFileStream.Format = SpAudio;
SpFileStream.Open(path, SpFileMode, false);
voice.AudioOutputStream = SpFileStream;
voice.Speak(str, SpFlags);
voice.WaitUntilDone(Timeout.Infinite);
SpFileStream.Close();
return File.Exists(path);
}