In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech.

在本教程中,我将向您展示如何在Delphi中使用Windows Speech API。 我将仅介绍一些基本功能,例如文本到语音以及控制语音速度。

SAPI Installation

SAPI安装

First you need to install the SAPI type library, the type library is attached to this tutorial, into Delphi.

首先,您需要将SAPI类型库(此教程附带的类型库)安装到Delphi中。

In the Delphi IDE install a new component via the menu:

在Delphi IDE中,通过菜单安装新组件:

Component > Install Component...   (See Step 1 Image)

组件>安装组件...(请参阅第1步映像)

Select the 'Into new package' Tab, then click on the 'Browse' button, Select the '.PAS' file included in the type library attachment.   (See Step 2 Image)

选择“放入新软件包”选项卡,然后单击“浏览”按钮,选择类型库附件中包含的“ .PAS”文件。 (请参阅第2步图片)

Create a new package file name such as 'Speech.dpk'. Enter a package description such as 'Windows Speech API'. (See Step 2 Image)

创建一个新的程序包文件名,如“ Speech.dpk”。 输入程序包描述,例如“ Windows Speech API”。 (请参阅第2步图片)

Click on 'OK', when prompted to build then install the package, click on the 'Yes' button. (See Step 3 Image)

单击“确定”,当系统提示您进行构建,然后安装软件包时,单击“是”按钮。 (请参阅第3步图片)

You should get a prompt saying that new components have been installed. (See Step 4 Image)

您应该得到一个提示,说明已经安装了新组件。 (请参阅第4步图片)

Simple Text To Speech

简单的文字转语音

Create a new application.

创建一个新的应用程序。

Find the 'SpVoice' component, and drag it onto your form. (See Step 5 Image)

找到“ SpVoice”组件,然后将其拖动到表单上。 (请参阅第5步图片)

Add an edit box and a button to the form and, on the button onclick event handler, enter the following code:

在表单中添加一个编辑框和一个按钮,然后在按钮onclick事件处理程序上输入以下代码:

  1. procedure TForm1.Button1Click(Sender: TObject);

  2. begin

  3. if not (Edit1.Text = '') then

  4. SpVoice1.Speak(Edit1.Text, SVSFDefault);

  5. end;

When the user enters something into the textbox the SAPI says the text outloud. (See Step 6 Image).

当用户在文本框中输入内容时,SAPI会大声说出文本。 (请参阅第6步图片)。

Change Voice Speed

更改语音速度

Add a TrackBar component to your form (TrackBar is found in the win32 pallette). On the trackbar onchange event handler add the code below:

将TrackBar组件添加到窗体中(在Win32调色板中找到TrackBar)。 在轨迹栏onchange事件处理程序上,添加以下代码:

  1. procedure TForm1.TrackBar1Change(Sender: TObject);

  2. begin

  3. SpVoice1.Rate := TrackBar1.Position;

  4. end;

This trackbar will change the speed of the text to speech engine depending on where the trackbar is. It will make the voice either slower or faster; this may help the user understand the speech.

该跟踪栏将根据跟踪栏的位置来更改文本到语音引擎的速度。 它将使声音变慢或变快。 这可以帮助用户理解语音。

Run the project and you have a simple text to speech implementation in Delphi. This could be used to enable your application to speak to the user.

运行该项目,您将在Delphi中实现一个简单的文本到语音的实现。 这可用于使您的应用程序与用户对话。

I have attached the project files so you can use them for reference.

我已经附加了项目文件,因此您可以将其用作参考。

The tyle libraries cannot be attached, however they are here:

tyle库无法附加,但是它们在这里:

http://rapidshare.com/files/416314381/Speech_Type_Library.zip.html http://rapidshare.com/files/416314381/Speech_Type_Library.zip.html speech-tutorial.zip speech-tutorial.zip

翻译自: Using Windows Text to Speech with Delphi | Experts Exchange

delphi语音

delphi语音_在Delphi中使用Windows文本语音转换相关推荐

  1. python实现文字转语音_利用python实现自己的文本转语音

    1.安装python3.8.5 python   >>  downloads   >>   windows    >>  Windows x86-64 execut ...

  2. kind富文本编辑器_在项目中集成富文本编辑器

    前   言 现在学程序的都离不开 Markdown 语法了吧,Markdown 已经成为典型的转换为HTML的非正式规范和参考实现,现在市场上也出现了许多Markdown实现,在基本语法之上额外增加了 ...

  3. python如何把二进制转文本_在python3中如何把文本转换为二进制

    在python3中如何把文本转换为二进制 在python3中把文本转换为二进制的方法:首先修改dirroot为要读取的文件夹的路径:然后遍历所有的文件夹,读取txt文件:最后更改newdirroot为 ...

  4. VIM中去除Windows文本中的^M符号,多种方法

    总结起来就是: 1    :%s//r/  (推荐) 2    :%s//r//g 3    :%s/[ctrl-v][ctrl-m]//g(中间CTRL部分不是输入,而是按键,显示在屏幕上是  :% ...

  5. java windows域_域环境中的windows软件安装

    这几天要在单位部署一个软件包,是msi形式的,据说可以通过"域推送"的形式安装,搜索了一下,发现需要在 组策略->软件设置->软件安装 里面添加放在共享目录里的软件包. ...

  6. 中如何实现文字转语音_录音转文字、文字转语音,学会这一招就够了!手把手教你如何操作...

    阅读文章时候想着有人可以把文章读给我听就好了,写作时想着语音直接可以转换成文字就好了,大家是不是有时会突然冒出这样的想法?七十这些看似天真的想法,还真的有办法解决,这里就手把手教你如何操作才能将的文字 ...

  7. ROS语音交互系统_(3)ROS中接入图灵机器人语音理解系统

    前言 图灵机器人官网 1.提前安装依赖包 $ sudo apt install libcurl3 libcurl4-oppenssl-dev $ sudo apt install libjsoncpp ...

  8. java监听剪贴板_在java中实现windows剪贴板监视

    在google上搜了一把,结果搜到了自己原创的文章,不胜窃喜.于是重新格式化了一下,重发之. package com.ibm.bloghelper; import java.awt.datatrans ...

  9. java utf8 简繁转换 类库_在Java中进行中文繁体简体转换,基于OpenCC(Open Chinese Convert)方案...

    一.OpenCC介绍 OpenCC (Open Chinese Convert,开放中文转换) 是一个用于中文简繁转换的开源项目,支持词汇级别的转换.异体字转换和地区习惯用词转换(中国大陆.台湾.香港 ...

最新文章

  1. 相机居然能存储气味,未来智能家居会是什么样? | CCF C³
  2. Luogu P1160 【队列安排】
  3. go语言实现第一个程序-hello,world!
  4. 医院计算机管理在品管圈中的应用,品管圈在医院管理中怎么用?看完就明白了...
  5. Java基础语法之Map
  6. bat批处理教程 24
  7. C++_选择结构_循环结构_for循环_敲桌子案例_嵌套循环_乘法口诀案例_跳转语句break---C++语言工作笔记018
  8. php 文件上传$_FILES error错误码
  9. CentOs安装pyhive
  10. 校招行测笔试-图形推理
  11. java实现对接建行支付及其回调
  12. Word中快速输入公式
  13. katana 靶机 wp
  14. The YARN Timeline Service v.2
  15. MacBook Pro 2018款充电口不能用解决办法
  16. 敏捷管理 -- 时间和成本管理
  17. Visual SLAM: What are the Current Trends and What to Expect?
  18. sqlserver 下载地址(SQL Server 2008 R2 中英文 开发版/企业版/标准版 下载)
  19. 滚动字幕Marquee代码大全
  20. 三台宿主机使用docker搭建zookeeper集群

热门文章

  1. 如何实现一个React全家桶项目(附完整教程及代码)
  2. python读写文件,CSV和Excel
  3. 字符流与字节流的区别
  4. 送男友什么品牌蓝牙耳机好?双12音质无线蓝牙耳机
  5. 什么无线蓝牙耳机平价实惠?2022真无线蓝牙耳机排行榜
  6. SPSS单样本T检验在SPSS中的实战操作及结果解读(含SPSS输出结果及三线表)【转载】
  7. Iframe自适应高度
  8. 微信小程序云开发笔记
  9. WinCE选择并调用输入法
  10. 巧用Photoshop滤镜模拟水粉花卉效果(转)