TTS怎么用?(C++BUILDER)

NowCan 2000-07-17 06:14:00
TTS怎么用?(C++BUILDER)
我在电脑爱好者上看到过,但是DEPHI的,我试着改成了C++BUILDER程序,不料错误一堆,请教各位高手,怎么办?
...全文
184 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjzhuang 2001-05-16
  • 打赏
  • 举报
回复
呵呵,我刚搞定了一个:
启动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;
}
//---------------------------------------------------------------------------
Wingsun 2000-07-17
  • 打赏
  • 举报
回复
到www.borland.com.cn上去看一看。

13,822

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧