Main purpose: call Windows 7's own SAPI 5.4 (TTS) generated speech flow, and through the DSPack components around computer channel pronunciation respectively, due to the repeated use of high frequency, so did not generate audio files and generate speech flow, through the way of memory read,
To solve the problem and so on the Internet to search some articles, and in the
http://www.delphi2007.net/delphiblog/html/delphi_200711515440514966.html prompt revised DSpack, increased the
Function TFilterGraph. RendStream (Stream: TStream) : HRESULT; The method of
Here's the thing, in the call of TTS TSpMemoryStream class generation OleVariant type how to convert TStream let DSpack components read??????
In addition whether there's a better way, 1. As long as meet the TTS voice generated, (2) sound optional around a track which is similar to the Balance of the property, (3) to generate audio files on hard drives,
Thank you all for the great god, Daniel, eldest brother! Have not understand the problem, I always reply!!!!!!
SpMemoryStream1. Format. Type_ :=SAFT8kHz8BitMono;this paragraph is calling the TTS TSpMemoryStream generated (Music: OleVariant;) I do not know to have no?
SpMemoryStream1. SetData (Music);
Sp. AudioOutputStream:=SpMemoryStream1. DefaultInterface;
Sp. Speak (Memo1. Text, SVSFlagsAsync);
Sp. WaitUntilDone (1);
Music:=SpMemoryStream1. GetData;
CodePudding user response:
See what fits you (untested)Code 1:
Do you mean a variant array of bytes?
The function VarBytesFromStream (s: TStream; Size: integer) : OleVariant;
Var
P: pchar;
The begin
Result:=varArrayCreate ([0, the Size 1], VarByte);
P:=varArrayLock (Result);
Try
S.R ead (p ^, Size);
The finally
VarArrayUnlock (Result);
End
The end;
Procedure VarBytesToStream (const Value: OleVariant; S: TStream);
Var
P: pchar;
Size: integer;
The begin
Size:=VarArrayHighBound (the value 1) - VarArrayLowBound (value, 1) + 1;
P:=VarArrayLock (Value);
Try
S. rite (p ^, Size);
The finally
VarArrayUnlock (Value)
end;
end;
Code 2:
The function MemoryStreamToOleVariant (Strm: TMemoryStream) :
OleVariant;
Var
Data: PByteArray;
The begin
Result:=VarArrayCreate ([0, Strm. Size - 1], varByte);
Data:=VarArrayLock (Result);
Try
Strm. Position:=0;
Strm. ReadBuffer (Data ^ Strm. Size);
The finally
VarArrayUnlock (Result);
end;
end;
The function OleVariantToMemoryStream (OV: OleVariant) :
TMemoryStream;
Var
Data: PByteArray;
Size: integer;
The begin
Result:=TMemoryStream. Create;
Try
Size:=VarArrayHighBound (OV, 1) - VarArrayLowBound
(OV, 1) + 1;
Data:=VarArrayLock (OV);
Try
Result. The Position:=0;
Result. The WriteBuffer (Data ^, Size);
The finally
VarArrayUnlock (OV);
end;
Except,
Result. The Free;
Result:=nil;
end;
end;
CodePudding user response: