C#朗读语音

     最近有个需求,需要在C#程序发生异常时候,朗读文字,C#提供了.net framework可以提供简单的语音朗读功能。

引入依赖

using System.Media;
using System.Speech.Synthesis;
using System.Runtime.InteropServices;

//报警音量
SystemSounds.Exclamation.Play();
//设置阅读
SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
//音量
speechSynthesizer.Volume = 100;
//倍速
speechSynthesizer.Rate = 2;
//阅读
speechSynthesizer.SpeakAsync(message)

相关推荐

  1. C#朗读语音

    2024-06-08 03:24:04       9 阅读
  2. ChatGPT 新增朗读功能,支持 37 种语言

    2024-06-08 03:24:04       25 阅读
  3. 【PyQt6】朗读小说西游记

    2024-06-08 03:24:04       39 阅读
  4. c语言)goto语句

    2024-06-08 03:24:04       40 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-08 03:24:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-08 03:24:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-08 03:24:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-08 03:24:04       20 阅读

热门阅读

  1. 第3章 列表简介

    2024-06-08 03:24:04       13 阅读
  2. MySQL数据库(7)

    2024-06-08 03:24:04       10 阅读
  3. 快慢指针算法举例

    2024-06-08 03:24:04       8 阅读
  4. pytest +allure在测试中的应用

    2024-06-08 03:24:04       10 阅读
  5. Python笔记 - Lambda表达式

    2024-06-08 03:24:04       10 阅读
  6. Kotlin 注解

    2024-06-08 03:24:04       12 阅读
  7. Android14 WMS-Power键短按流程

    2024-06-08 03:24:04       6 阅读
  8. LeetCode 4 - 寻找两个正序数组的中位数

    2024-06-08 03:24:04       8 阅读
  9. redis7.0.x与mysql8.0.x离线docker镜像制作

    2024-06-08 03:24:04       10 阅读