当前位置: 首页 > news >正文

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

        private void 朗读文本(string text){DotNetSpeech.SpVoice sp = new DotNetSpeech.SpVoice();DotNetSpeech.SpeechVoiceSpeakFlags sFlags = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;sp.Speak(text, sFlags);}朗读文本("解答 专用 窗体.演示 朗读 文本");

C++ 

#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);
}
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.htmwhile (循环 < 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);}}
}

相关文章:

  • 【C语言入门级教学】assert断⾔和指针的使用
  • C++ - 标准库之 <sstream> ostringstream(ostringstream 概述、基本使用、清空内容、进阶使用)
  • Codeforces Round 1026 (Div. 2) C. Racing
  • 【笔记】为 Python 项目安装图像处理与科学计算依赖(MINGW64 环境)
  • 树欲静而风不止,子欲养而亲不待
  • 打开一个新的Maven工程要做的事情
  • 基于 StarRocks + Iceberg,TRM Labs 构建 PB 级数据分析平台实践
  • R语言基础| 创建数据集
  • langGraph多Agent
  • PH热榜 | 2025-06-02
  • Spring Boot中保存前端上传的图片
  • React 18 生命周期详解与并发模式下的变化
  • openai-java
  • 企业级开发中的 maven-mvnd 应用实践
  • 免费的硬盘工具
  • 电子电气架构 --- 后轮转向的一点事情
  • BUUCTF[ACTF2020 新生赛]Include 1题解
  • 《QDebug 2025年5月》
  • 2024年第十五届蓝桥杯Scratch10月stema选拔赛真题——数字卡片排序
  • [蓝桥杯]交换次数
  • 花木网站建设/品牌策划书
  • 医药公司网站建设/网站数据查询
  • 腾讯微校怎么做微网站/网络营销在哪里学比较靠谱
  • 西安推荐企业网站制作平台/自己创建一个网站需要多少钱
  • 网站建设四川推来客网站系统/58和百度哪个推广效果好
  • 郑州做网站公司天强科技/上海培训机构排名