Use TTS (Text to Speech) in C ++ Builder

zhaozj2021-02-08  206

Start the BCB, open the menu item Project-> Import Type library ..., click Add in the pop-up dialog box, select VtxtAuto.tlb under the Windows / Speech directory, join the vtxtAuto [Version 1.0]. Click OK, BCB will automatically generate a vtxtauto_tlb.cpp file. This file contains the COM class interface of the TTS engine, which can be used to communicate with the DLL file.

Create this project, contain this file coming in: The source code is as follows: //unit.h#ifNDEF Unit1H # define unit1H // ------------------------ -------------------------------------------------- - # include #include #include #include // ------------------- -------------------------------------------------- ------ class TForm1: public TForm {__ published: // IDE-managed Components TEdit * Edit1; TButton * Button1; void __fastcall FormCreate (TObject * Sender); void __fastcall Button1Click (TObject * Sender); private: // User declarationspublic: // user declarations __fastcall tform1 (tcomponent * owner);}; // ------------------------------- ---------------------------------------------------------------------------- EXTERN PACKAGE TFORM1 * FORM1; / / -------------------------------------------------------------------------------------------- --------------------------- # Endif // Unit.cpp // -------------- -------------------------------------------------- ----------- # include #pragma hdrstop # incrude "Unit1.h" #include "wstring.h" #include "vtxtAuto_t LB.H "// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------ # pragma package (smart_init) #pragma resource "* .dfm" TFORM1 * FORM1; IVTXTAUTO * Ivtxtauto1; // --------------------------------------------- ------------------------------__ fastcall tform1 :: tform1 (tcomponent * oowner): 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);

转载请注明原文地址:https://www.9cbs.com/read-2271.html

New Post(0)