我们有一个MVC网站,现在我们想添加一个功能,我们希望能够在客户端读出文本。我们显示一组发票,并且想要读出发票明细。我知道你可以在桌面应用程序中使用System.Speech库,通过传递细节来读取它,但有人知道我们如何在MVC项目中做到这一点。ASP.NEt MVC文本到语音
2
A
回答
2
好吧,这只是我的头的顶部,它尚未经过测试,但你也许可以做这样的事情:
public ActionResult Speak(string text)
{
var speech = new SpeechSynthesizer();
speech.Speak(text);
byte[] bytes;
using (var stream = new MemoryStream())
{
speech.SetOutputToWaveStream(stream);
bytes = stream.ToArray();
}
return File(bytes, "audio/x-wav");
}
0
我研究,我发现这种方式,其类似约翰Kalberer的回答是:
public async Task<ActionResult> Index()
{
Task<FileContentResult> task = Task.Run(() =>
{
using (var synth = new SpeechSynthesizer())
{
synth.SelectVoice("Microsoft Sabina Desktop");
using (var stream = new MemoryStream())
{
synth.SetOutputToWaveStream(stream);
synth.Speak("hola mundo");
byte[] bytes = stream.GetBuffer();
return File(bytes, "audio/x-wav");
}
}
});
return await task;
}
在这种情况下,我使用的是西班牙语的声音,当然你可以选择你的声音或避免synth.SelectVoice
并使用predeterminated
相关问题
- 1. 语音/语音到文本
- 2. ASP.NET文本到语音错误
- 3. 文本到语音(语音生成)和语音到文本(语音识别)API?
- 4. 文本到语音
- 5. 文本到语音
- 6. Android文本到语音男性语音
- 7. 通用文本到语音语音
- 8. 语音识别和文本到语音
- 9. 语音到文本 - Alexa语音服务
- 10. iphone开发:语音到文本和文本到语音
- 11. 用于“文本到语音”和“语音到文本”的C++ API
- 12. Windows 8语音文本和文本到语音API
- 13. Android文本语音切断另一个文本到语音
- 14. 文本到语音Api
- 15. android文本到语音(tts)
- 16. 文本到语音在android
- 17. 钛文本到语音
- 18. SAPI 5.3语音到文本
- 19. 文本到语音软件
- 20. java文本到语音api
- 21. Android文本到语音
- 22. Android Angularjs文本到语音
- 23. 快速文本到语音
- 24. AppleScript - 语音到文本
- 25. silverlight文本到语音?
- 26. 文本到语音错误
- 27. 语音到文本识别
- 28. 文本到语音Android
- 29. 文本到语音崩溃
- 30. Android文本到语音