【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);
        }

    }
}
相关推荐
DanmF--30 分钟前
C#面向对象实践项目--贪吃蛇
开发语言·游戏·c#·游戏程序
东京老树根40 分钟前
SAP学习笔记 - 开发18 - 前端Fiori开发 应用描述符(manifest.json)的用途
笔记·学习
m0_678693331 小时前
深度学习笔记25-RNN心脏病预测(Pytorch)
笔记·rnn·深度学习
我的golang之路果然有问题1 小时前
快速了解GO+ElasticSearch
开发语言·经验分享·笔记·后端·elasticsearch·golang
凤年徐2 小时前
【数据结构初阶】顺序表的应用
c语言·开发语言·数据结构·c++·笔记·算法·顺序表
love530love2 小时前
Windows 下部署 SUNA 项目:虚拟环境尝试与最终方案
前端·人工智能·windows·后端·docker·rust·开源
凌康ACG3 小时前
易语言使用OCR
c++·yolo·c#·ocr·易语言
InCerry3 小时前
.NET 9中的异常处理性能提升分析:为什么过去慢,未来快
c#·.net·高性能
半导体守望者3 小时前
英福康INFICON VGC501, VGC502, VGC503 单通道、双通道和三通道测量装置
经验分享·笔记·功能测试·自动化·制造
BIBI20494 小时前
Windows 下彻底删除 VsCode
windows·vscode