У меня есть этот код, и он отлично работает, но я изо всех сил пытаюсь получить его для вывода wav-файла, который может быть встроен в страницу, а не для того, чтобы пользователь загружал и слушал. Любая помощь очень ценится. Я хотел бы иметь возможность напрямую вызвать файл с помощью строки запроса, чтобы он соответствовал текстуу перехвата. Model.InstanceData ["Код"] - это штрих-код в текстовой строке. Я просто не могу показаться, что обманываю его. Благодаря!Текст в речь с использованием встроенного
private void _playBtn_Click(object sender, ImageClickEventArgs e)
{
HttpContext context = HttpContext.Current;
if (context == null || context.Response == null)
{
return;
}
context.Response.Clear();
context.Response.AddHeader("content-disposition", "attachment; filename=" + "captcha.wav");
context.Response.AddHeader("content-transfer-encoding", "binary");
context.Response.ContentType = "audio/wav";
SoundGenerator soundGenerator = new SoundGenerator(Model.InstanceData["Code"]);
MemoryStream sound = new MemoryStream();
// Write the sound to the response stream
soundGenerator.Sound.Save(sound, SoundFormatEnum.Wav);
sound.WriteTo(context.Response.OutputStream);
}