小编fri*_*itz的帖子

SpeechSynthesizer .NET控制音高

我试图通过SSML和.NET SpeechSynthesizer(System.Speech.Synthesis)改变语音文本的音高

SpeechSynthesizer synthesizer = new SpeechSynthesizer();
PromptBuilder builder = new PromptBuilder();
builder.AppendSsml(@"C:\Users\me\Documents\ssml1.xml");
synthesizer.Speak(builder);
Run Code Online (Sandbox Code Playgroud)

ssml1.xml文件的内容是:

<?xml version="1.0" encoding="ISO-8859-1"?>
<ssml:speak version="1.0"
xmlns:ssml="http://www.w3.org/2001/10/synthesis"
xml:lang="en-US">
<ssml:sentence>
Your order for <ssml:prosody pitch="+30%" rate="-90%" >8 books</ssml:prosody>
will be shipped tomorrow.
</ssml:sentence>
</ssml:speak>
Run Code Online (Sandbox Code Playgroud)

价格被认可:"8本书"比其他人说得慢得多,但无论"音调"的价值是多少,都没有区别!允许的值可以在这里找到:

http://www.w3.org/TR/speech-synthesis/#S3.2.4

我错过了什么或正在改变微软语音引擎不支持的音调?

弗里茨

c# text-to-speech

11
推荐指数
1
解决办法
4143
查看次数

为什么Wpf的DrawingContext.DrawText如此昂贵?

在Wpf(4.0)中,我的列表框(使用VirtualizingStackPanel)包含500个项目.每个项目都是自定义类型

class Page : FrameworkElement
...
protected override void OnRender(DrawingContext dc)
{
   // Drawing 1000 single characters to different positions
   //(formattedText is a static member which is only instantiated once and contains the string "A" or "B"...)
   for (int i = 0; i < 1000; i++)
     dc.DrawText(formattedText, new Point(....))


  // Drawing 1000 ellipses: very fast and low ram usage
    for (int i = 0; i < 1000; i++)     
    dc.DrawEllipse(Brushes.Black, null, new Point(....),10,10)


}
Run Code Online (Sandbox Code Playgroud)

现在,当来回移动列表框的滚动条时,每个项目的视觉效果至少创建一次,一段时间内ram的使用量达到500 Mb,然后 - 过了一会儿 - 回到250 Mb但仍然保持在这个水平.内存泄漏 …

c# wpf drawing

9
推荐指数
2
解决办法
1万
查看次数

Wpf的InteropBitmap和GDI +:高CPU使用率

我创建了一个小的wpf测试应用程序,它使用System.Drawing.Graphics和wpf的InteropBitmap每30毫秒呈现一些随机矩形.我认为InteropBitmap会比WriteableBitmap更快:它能够从内存部分更新自己.

在执行应用程序(屏幕大小1600*1200)时,使用双核3GHz ,应用程序的CPU使用率仅为2-10%.但整体CPU使用率约为80-90%,因为"系统(NT内核和系统")进程上升到70%!编辑:我注意到RAM使用在15秒内定期增加超过1 GB,然后突然回落到正常水平,依此类推.

也许以下代码可以优化?:

namespace InteropBitmapTest{

 using System;
 using System.Drawing;
 using System.Runtime.InteropServices;
 using System.Windows;
 using System.Windows.Interop;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using Color = System.Drawing.Color;

public partial class Window1 : Window
{

    private System.Drawing.Bitmap gdiBitmap;
    private Graphics graphics;


    InteropBitmap interopBitmap;

    const uint FILE_MAP_ALL_ACCESS = 0xF001F;
    const uint PAGE_READWRITE = 0x04;

    private int bpp = PixelFormats.Bgr32.BitsPerPixel / 8;

    private Random random;
    private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();


    SolidBrush[] brushes = new …
Run Code Online (Sandbox Code Playgroud)

c# wpf interop gdi+

5
推荐指数
1
解决办法
4549
查看次数

标签 统计

c# ×3

wpf ×2

drawing ×1

gdi+ ×1

interop ×1

text-to-speech ×1