Home > Back-end >  How to let the TTS with DSPK after 5.4 generation WAV type TSpMemoryStream flow components from memo
How to let the TTS with DSPK after 5.4 generation WAV type TSpMemoryStream flow components from memo

Time:12-15

Development environment for Windows 7 Delphi7

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; 
SpMemoryStream1. SetData (Music);
Sp. AudioOutputStream:=SpMemoryStream1. DefaultInterface;
Sp. Speak (Memo1. Text, SVSFlagsAsync);
Sp. WaitUntilDone (1);
Music:=SpMemoryStream1. GetData;
this paragraph is calling the TTS TSpMemoryStream generated (Music: OleVariant;) I do not know to have no?

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:

reference 1st floor FRTRNR response:
and 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
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;
code 2 has been tried before and after the transformation seems wrong format failed to voice,
Just try your code in a procedure VarBytesToStream (const Value: OleVariant; S: TStream) method; Debugging in s. rite (p ^, Size); Times wrong, wrong is shown in figure, where is it? Please advise, thank you!

CodePudding user response:

Tested, the TTS TSpMemoryStream generated in the memory of the voice stream, to char type conversion, data results and the actual output file wav files (note: the voice broadcast content is as follows: 1234) is far, to Byte type conversion, the result is not consistent,
Excuse me, TTS TSpMemoryStream is voice stream output???????? Or is my TSpMemoryStream using is wrong, please teach a great god!

CodePudding user response:

His top! Seek expert help!
TTS output flow of memory, is supported??????

CodePudding user response:

Hi,
I want to download SAPI5.4 version for Windows XP, but couldn't find it download address? Who have?
  • Related