[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1228
  • Last Modified:

How to save SAPI text to speech into a wave format thru TMemoryStream

I'm working on a TTS project. I want to output it to a wave format to TMemoryStream instead of saving to a file. The reason of saving to TMemoryStream so that I can play it in bass (http://www.un4seen.com/). I added codes from a questions posted here that save to wave file. Could someone help me?
The codes below save output to wave file. I got it from http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20642945.html.
procedure TForm1.Button1Click(Sender: TObject);
var SpFileStream1: TSpFileStream;
    SpVoice1: TSpVoice;
    FileName : TFileName;
    Button1.Caption := 'Working';
    SpFileStream1 := TSpFilestream.Create(nil);
    FileName := 'E:\Test1.wav';
    SpFileStream1.open(FileName, SSFMCreateForWrite, false);
    SPVoice1 := TSpVoice.Create(nil);
    SpVoice1.AudioOutputStream := SPFileStream1.DefaultInterface;
    SpVoice1.Speak('this is a test', SVSFDefault);
    Button1.Caption := 'done';

Open in new window

  • 2
  • 2
1 Solution
MerijnBSr. Software EngineerCommented:
If you can compile this code, can't you change TSpFileStream to TSpMemoryStream?
edeauxAuthor Commented:
TSpMemoryStream isn't compatible with bass.
edeauxAuthor Commented:
To Moderator:

Is it possible to reclaim the points I assigned? I already find a solution with my problem.
MerijnBSr. Software EngineerCommented:
You can click the 'request attention' link for these kind of things, I've already done that for you now.

If you have a solution, please post it here for future reference.

(btw, I'd expected bass not to except TSpMemoryStream, but there are probably ways around that).

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now