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

Posted on 2009-02-11
Last Modified: 2013-11-23
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 ( 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

procedure TForm1.Button1Click(Sender: TObject);

var SpFileStream1: TSpFileStream;

    SpVoice1: TSpVoice;

    FileName : TFileName;


    Button1.Caption := 'Working';

    SpFileStream1 := TSpFilestream.Create(nil);

    FileName := 'E:\Test1.wav';, SSFMCreateForWrite, false);

    SPVoice1 := TSpVoice.Create(nil);

    SpVoice1.AudioOutputStream := SPFileStream1.DefaultInterface;

    SpVoice1.Speak('this is a test', SVSFDefault);




    Button1.Caption := 'done';


Open in new window

Question by:edeaux
    LVL 19

    Expert Comment

    If you can compile this code, can't you change TSpFileStream to TSpMemoryStream?

    Author Comment

    TSpMemoryStream isn't compatible with bass.

    Accepted Solution

    To Moderator:

    Is it possible to reclaim the points I assigned? I already find a solution with my problem.
    LVL 19

    Expert Comment

    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

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now