安装完Microsoft  Speech  SDK  5.1,
Microsoft  Speech  SDK  5.1的中文语音引擎后
在Delphi 6中调用SpVoice1控件只能发默认的英文,
在VB中只要用
Set SpVoice1.Voice = SpVoice1.GetVoices.Item(3)
就可以发中文,
不只道在Delphi中应怎样写?谢谢!!!

解决方案 »

  1.   

    关注,你可以查看关于Microsoft Speech SDK的帮助,应该有其他程序开发平台怎么调用它的相关语言
      

  2.   

    Dear My_first,
    请发一个读中文的例子给我,万分感谢!
    李生
    [email protected]
      

  3.   

    转贴:VB和Delphi之间的转换:VB to DLLQ:  How Do I pass the following struct from VB to a Delphi created DLL **by reference** would be appreciated (what should the parameters on the Delphi side look like?).  I chose this structure to sort of represent most scenarios (if I can successfully pass this one, anything should be OK)Type MyType
       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).
      

  4.   

    // 偶前几天刚写过这方面的东东,你可以参考一下// 在一个ComboBox中列出可用的发音者
    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;