【C#朗读文本DLL动态按钮控件组及按钮事件文本框拖放数据】2022-1-21

缘由https://bbs.csdn.net/topics/604357098 DotNetSpeech.dll下载_DotNetSpeech.dll免费版下载 - 系统之家 dotnetspeech.dll 64下载-dotnetspeech.dll下载 v10.2 官方版-IT猫扑网

下载了一个DotNetSpeech.dll,放到 \bin\Debug里,添加引用,然后直接DotNetSpeech.SpVoice sp = new DotNetSpeech.SpVoice();朗读速度(-10,10)

cpp 复制代码
        private void 朗读文本(string text)
        {
            DotNetSpeech.SpVoice sp = new DotNetSpeech.SpVoice();
            DotNetSpeech.SpeechVoiceSpeakFlags sFlags = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
            sp.Speak(text, sFlags);
        }



朗读文本("解答 专用 窗体.演示 朗读 文本");

C++

cpp 复制代码
#using "..\Debug\农历引用.dll"
using namespace 农历引用;



string 返回月历(int 年, int 月, int 日, bool 选 = true)
{
	系统农历^ 农历 = gcnew 系统农历();
	string aa = ((CT2A)(CString)(农历->月历加载(年, 月, 日))), aaa = "";
	aaa.push_back(aa[8]); aaa.push_back(aa[9]); aaa.push_back(aa[10]); aaa.push_back(aa[11]);
	return (选 ? aa : aaa);
}
cpp 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 文本朗读转音频
{
    public partial class Form1 : Form
    {
        TextBox 录入框 = new TextBox();
        ToolTip 控件说明 = new ToolTip();
        Button[] 按钮集 = { };
        ImageList 图标集 = new ImageList();
        StatusBar 状态栏 = new StatusBar();
        
        public Form1()
        {
            InitializeComponent();
            this.ResizeRedraw = true;
        }
        private void Form1_Resize(object sender, EventArgs e)
        {
            尺寸();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            初值(); 布局(); 尺寸(); 停靠(); 跟随(); 注明(); 图标(); 事件();

            
        }
        private void 动态文本框_DragDrop(object sender, DragEventArgs e)
        {
            录入框.Text += (System.String)e.Data.GetData(typeof(System.String));
        }
        private void 动态文本框_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = (e.Data.GetDataPresent(typeof(System.String))) ? DragDropEffects.Copy : DragDropEffects.None;
        }
        private void 朗读文本单击(object sender, EventArgs e) { 朗读文本(录入框.Text); }
        private void 朗读文本(string text)
        {
            
            DotNetSpeech.SpVoice sp = new DotNetSpeech.SpVoice();
            DotNetSpeech.SpeechVoiceSpeakFlags sFlags = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
            sp.Speak(text, sFlags);//朗读效果不满意不复再编写
        }
        void 友情提示(string 内容) { MessageBox.Show(内容, "友情提示:"); }
        void 控件异步处理(Action 无返回事件)
        {
            Parallel.Invoke(delegate()
            {
                this.BeginInvoke(new Action(delegate()
                {
                    无返回事件();
                }));
            });
        }
        void 图标()
        {
            this.Invoke(new Action(() =>
            {
                int 循环 = 0;//ICOhttps://sc.chinaz.com/tubiao/180520455660.htmhttps://sc.chinaz.com/tubiao/948547132.htmhttps://sc.chinaz.com/tubiao/954045391.htm
                while (循环 < 11)
                    图标集.Images.Add(Image.FromFile(@System.Environment.CurrentDirectory + "\\ICO\\BF" + 循环++.ToString() + ".ico"));
            }));
        }
        void 尺寸()
        {
            录入框.Size = new Size(this.Width - 24, this.Height - (状态栏.Height) - 68);
        }
        void 停靠()
        {
            状态栏.Parent = 录入框.Parent = this;
            按钮集.Select(按钮 => 按钮.Parent = this).ToArray();
        }
        void 跟随()
        {
            录入框.Anchor = (AnchorStyles.Top | AnchorStyles.Left);
        }
        void 布局()
        {
            录入框.Location = new Point(4, 24);
            按钮集.Select((按钮, 序号) => 按钮.Location = new Point(47 * 序号, 1)).ToArray();
        }
        void 注明()
        {
            控件说明.SetToolTip(录入框, "请输入数据文本以便进行朗读语音数据保存。");
        }
        void 初值()
        {
            this.BackColor = Color.Red;

            录入框.AllowDrop = true;
            录入框.Multiline = true;
            录入框.AcceptsReturn = true;
            录入框.ScrollBars = ScrollBars.Both;
            录入框.ImeMode = System.Windows.Forms.ImeMode.OnHalf;
            录入框.MaxLength = int.MaxValue;

            string[] 按钮名 = new string[] { "朗读", "暂停", "继续", "停止", "录制" };
            按钮集 = Array.ConvertAll(按钮名, 控件 => new Button()).ToArray();
            按钮集.Select((按钮, 序号) => 按钮.Text = 按钮名[序号]).ToArray();
            按钮集.Select(按钮 => 按钮.Size = new Size(47, 24)).ToArray();
        }
        void 事件()
        {
            按钮集[0].Click += new EventHandler(朗读文本单击);
            //按钮集[1].Click += new EventHandler(暂停单击);
            //按钮集[2].Click += new EventHandler(继续单击);
            //按钮集[3].Click += new EventHandler(停止单击);
            //按钮集[4].Click += new EventHandler(输出WAV单击);
            录入框.DragDrop += new DragEventHandler(动态文本框_DragDrop);
            录入框.DragEnter += new DragEventHandler(动态文本框_DragEnter);
        }

    }
}
相关推荐
一隅论数智6 天前
给AI一张“业务概念地图“:本体如何从哲学走向企业智能
大数据·人工智能·经验分享·笔记·学习·学习方法·政务
上海广测检测科技有限公司6 天前
智能平板出口巴西合规详解:Anatel射频、Inmetro电源/电池与LGPD数据合规叠加
经验分享
小羊没烦恼!6 天前
初探性能优化——2个月到4小时的性能提升
java·开发语言·windows·算法·c#
rockmelodies6 天前
# Windows Server2008 R2 Standard(SP1镜像U盘)重置本地管理员密码【完整详细步骤】
windows·密码破解
神仙别闹6 天前
基于C#+MySQL实现(WinForm)个人聊天室软件
c#
liufeiyu19766 天前
VS 2026 升级后出现错误: 找不到指定的 SDK“Microsoft.NET.Sdk”
visual studio·vs 2026
FLJwu6 天前
存储与固件量产实战01:运动相机TF卡量产翻车实录!V30≠4K可用,90%OEM踩中的隐形售后坑
经验分享·数码相机·相机
深圳老胡6 天前
STM32F407 控制 L6470 步进电机驱动 —— 控制过程简介
笔记·stm32·单片机·嵌入式硬件·代码规范
xiaomu001236 天前
床垫选型的技术评估模型:结构、材料、卫生与检测四层口径
经验分享
Because_of_Her16 天前
并查集-听课笔记
笔记·算法·并查集