当前位置: 首页 > 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);}}
}

http://www.lqws.cn/news/67285.html

相关文章:

  • SpringBoot(六)--- AOP、ThreadLocal
  • Windows 账号管理与安全指南
  • 【软件测试】测试框架(unittest/pytest)
  • 助力活力生活的饮食营养指南
  • 【C语言预处理详解(下)】--#和##运算符,命名约定,命令行定义 ,#undef,条件编译,头文件的包含,嵌套文件包含,其他预处理指令
  • unity开发棋牌游戏
  • Unity + HybirdCLR热更新 入门篇
  • mac安装brew时macos无法信任ruby的解决方法
  • 【Unity】相机 Cameras
  • 【笔记】解决虚拟环境中找不到 chromedriver 的问题
  • 如何自动部署GitLab项目
  • 【黑马程序员uniapp】项目配置、请求函数封装
  • 铁电液晶破局 VR/AR:10000PPI 重构元宇宙显示体验
  • c++泛型编程入门与STL介绍
  • 【算法】回溯法
  • 强大的PDF编辑工具,操作方便 ,长久使用
  • Python数学可视化——显函数、隐函数及复杂曲线的交互式绘图技术
  • 【LLM vs Agent】从语言模型到智能体,人工智能迈出的关键一步
  • 三大模块曝光:分钟级搭建专属平台,解锁算力灵活操控新体验,重新定义智能开发效率天花板
  • 专业C++Qt开发服务,助力您的软件项目腾飞!
  • 【C#】Quartz.NET怎么动态调用方法,并且根据指定时间周期执行,动态配置类何方法以及Cron表达式,有请DeepSeek
  • 谷歌CEO皮查伊眼中的“下一代平台“与未来图景
  • Linux运维笔记:服务器安全加固
  • 【C++】类的构造函数
  • 信号处理基础到进阶再到前沿
  • 【Elasticsearch】ILM(Index Lifecycle Management)策略详解
  • Deepseek给出的8255显示例程
  • Linux --TCP协议实现简单的网络通信(中英翻译)
  • vscode 插件 eslint, 检查 js 语法
  • Cursor 编辑器介绍:专为程序员打造的 AI 编程 IDE