安装完Microsoft Speech SDK 5.1,
Microsoft Speech SDK 5.1的中文语音引擎后
在Delphi 6中调用SpVoice1控件只能发默认的英文,
在VB中只要用
Set SpVoice1.Voice = SpVoice1.GetVoices.Item(3)
就可以发中文,
不只道在Delphi中应怎样写?谢谢!!!
Microsoft Speech SDK 5.1的中文语音引擎后
在Delphi 6中调用SpVoice1控件只能发默认的英文,
在VB中只要用
Set SpVoice1.Voice = SpVoice1.GetVoices.Item(3)
就可以发中文,
不只道在Delphi中应怎样写?谢谢!!!
解决方案 »
- 求助。构建FloatToStrF函数。
- 如何将同结构的数据库合并成一个大数据库
- 如何把一个string型的串放入一个byte数组?
- 请教delphi高手,急。。。。
- 问个问题,一个文本编辑软件,需要里面也可以插图,需要如何读取、保存资料?用什么控件最理想?
- ★★★★★ 机器上有多块网卡,Broland SocketServer 怎么绑定其中的一个ip? ★★★★★
- 怎样设置TDATABASE 和TQUERY
- HELP!!!谁会二叉树映象啊???
- 一个关于DateTimepicker控件OnUserInput事件的问题
- 用midas开发多层应用系统,设置问题,一筹莫展,大虾请进,高分奉送
- 显示要闪烁,怎么解决?
- 想购买一套人事管理系统的源代码!!!!!!!!!!!!!!!!!!!!!!!
请发一个读中文的例子给我,万分感谢!
李生
[email protected]
Value1 As Double Value2 As Integer
Value3 As String * 20
Value4 As String
End Type
A: You will have some trouble with Value4. Passing VB strings to/from DLLs takes special handling. The easiest way to do it is to pass a pre-declared VB string to the DLL and have the DLL return the length and the resulting string back.The others are easy. Value1 As Double -> Value1 : Longint;
Value2 AS Integer -> Value2 : integer;
Value3 As String * 20 -> Value3 : array[0..19] of char;User defined structures in Pascal are called records. type
myStructure = record
Value1 : longint;
Value2 : integer;
Value3 : array [0..19] of char;
end;I think you could define Value4 as a PChar in Pascal, but when you got it back in VB, you would have to search it for the ASCII 0 end byte and change the length of your string to the number of characters before the zero.If I remeber correctly, from my evaluation 'beta' copy with source code, there were some functions in the VCL that handle VB strings. Can't say if they are in the shipping version because I havn't recieved the VCL source yet. A quick search of the online docs don't reveal them.Here's some general type conversions from VB to Pascal (in table form; I hope this formats correctly on CIS.): VB Declare As VB Call With Translates to Pascal Type
------------- ------------ -------------------------
By Val S As String Any String or Variant PChar
I As Integer Any Integer ^Integer (pointer to integer)
L As Long Any Long ^Longint (pointer to longint) S As Rect Any Variable of same type ^TRect (pointer to TRect)
By Val As Integer Any Integer BOOL (word boolean)
" " " Word
" " " Integer
" " " hWnd
" " " hDC
" " " ...and so on; all word types.
By Val As Long Any Long Longint I As Integer the first element of I(0) ^array of integer
As Any Any Variable (By Val when
String) Pointer (PChar when string)
As Any By Val 0& nil
Q: This would probably work, but I'd still really like to know how to return a string (even a null-terminated one) from a DLL function to VB.A: The problem with returning PChars from DLLs is that the DLL has to be responsible for cleaning up the memory, but it doesn't know when the caller finishes. Most people use the following style, which is NOT bullet proof, but works in most instances: Var ReturnBuffer :Array [0..255] of Char; { Must be outside function! } function Dir_Get(ACaption, AInitDir, DirText: PChar ) : PChar;
Begin
...
Result := StrPCopy(ReturnBuffer, 'Result Text');
End;The only time you have a problem is when someone calls the function while someone else is still using the ReturnBuffer. (Just about guaranteed not to happen, except maybe under Windows 95, but could under 3.1 if VB doesn't copy the string).
procedure Tf_Main.FormCreate(Sender: TObject);
var
I: Integer;
T: ISpeechObjectToken;
begin
with SpVoice.GetVoices('', '') do
for I := 1 to Count - 1 do
begin
T := Item(I);
cb_Voice.Items.AddObject(T.GetDescription(0), TObject(T));
T._AddRef; // 避开系统自动调用的(_Release);
if Count > 0 then
begin
cb_Voice.ItemIndex := 0;
cb_Voice.OnChange(cb_Voice);
end;
end;
end;// 更改发音人
procedure Tf_Main.cb_VoiceChange(Sender: TObject);
begin
with cb_Voice do
SpVoice.Voice := ISpeechObjectToken(Pointer(Items.Objects[ItemIndex]));
end;