当前位置:七道奇文章资讯编程技术VC/C++编程
日期:2011-03-22 13:54:00  来源:本站整理

在C++ Builder中利用TTS(Text To Speech)[VC/C++编程]

赞助商链接



  本文“在C++ Builder中利用TTS(Text To Speech)[VC/C++编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:

启动BCB,翻开菜单项PROJECT->Import Type Library...,在弹出的对话框中单击Add,挑选windows\speech目录下的Vtxtauto.tlb,加入VtxtAuto[Version 1.0]一项.单击OK,BCB就会自动生成一个VtxtAuto_TLB.cpp文件.这个文件包含了TTS引擎的COM类接口,可以用来与DLL文件通信.新建一个工程,将这个文件包含进来:

源码以下:

//Unit.h
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TEdit *Edit1;
TButton *Button1;
void __fastcall FormCreate(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//Unit.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "wstring.h"
#include "VTxtAuto_TLB.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
IVTxtAuto *IVTxtAuto1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
WideString a = "Demo1";
WideString b = "Project1.exe";
WideString c= "Hi,I am trying to speak to you,Do you hear me?";
IVTxtAuto1 = NULL;
CoInitialize(NULL);
OleCheck(CoCreateInstance(CLSID_VTxtAuto_,0,CLSCTX_ALL,IID_IVTxtAuto, (LPVOID*)&IVTxtAuto1));
IVTxtAuto1->Register(a,b);
IVTxtAuto1->set_Enabled(1);
IVTxtAuto1->set_Speed(150);
IVTxtAuto1->Speak(c,vtxtsp_VERYHIGH);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(IVTxtAuto1 != NULL)
{
IVTxtAuto1->Speak((WideString)Edit1->Text,vtxtsp_VERYHIGH);
ShowMessage("OK");//我的调试语句(没声卡)
}else{
ShowMessage("服务器没有初始化成功");
}
}
//---------------------------------------------------------------------------
//Project.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
USERES("Project1.res");
USEFORM("Unit1.cpp", Form1);
USEUNIT("D:\Borland\CBuilder5\Imports\VTxtAuto_TLB.CPP");
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
//---------------------------------------------------------------------------

还可以操纵Variant利用TTS


  以上是“在C++ Builder中利用TTS(Text To Speech)[VC/C++编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • 高配置机械在CC攻击需求做的调整
  • Windows7与XP 双系统同时安装在C盘的办法
  • 在Centos 5.2上安装Xen并成立windows 2003虚拟机
  • 在CentOS 上编译安装Memcached
  • 在CentOS 6.0安装LAMP服务器(Apache2+PHP5+MySQL)
  • 若何让QVOD播放器不在C盘建media文件而在E盘建呢~
  • <b>在CentOS下通过源码 编译安装Xen 4.1.1</b>
  • <b>在CentOS 6.0 上安装LAMP服务器( Apache2 + PHP5 + MySQL)</b>
  • 如安在CentOS安装ispCP虚拟主机掌握面板
  • <b>如安在CentOS 5.5上安装Kippo蜜罐</b>
  • 在CentOS下安装webmin的具体流程
  • <b>在CentOS下安装webmin流程</b>
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .