Is it possible to stream text-to-speech results directly to Azure Blob Storage?

Steffen Schreiber 0 Reputation points


I am building an app in node.js and I would like to stream the results from a call to the text-to-speech service directly to an Azure Blob Storage without first streaming the data to the server on which the app is running. Is this possible?

Currently, I am using speakSsmlAsync to retrieve audio and viseme data on the server the app is running on, but I want to reduce the amount of data going through this server by passing the audio and viseme data directly to an Azure Blob Storage.

Can this be done from an app hosted on a third-party server? Would it be easier (or possible at all) to do this from an app hosted on Azure App Service?

Thanks for any hints!

Best regards,

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,153 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,093 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. YutongTie-MSFT 40,016 Reputation points

    Hello @Steffen Schreiber

    Thanks for reaching out to us, based on my personal experience, you may want to try createWriteStreamToBlockBlob method.

    Reference - []

    It is possible to stream text-to-speech results directly to Azure Blob Storage without first streaming the data to the server on which the app is running. You can do this by using the createWriteStreamToBlockBlob method provided by the azure-storage package for Node.js.

    A quick sample you may want to refer to, please adjust it according to your scenario -

    const azure = require('azure-storage');
    const textToSpeech = require('your-text-to-speech-module');
    // Create a reference to the Azure Blob Storage container
    const containerName = 'your-container-name';
    const blobService = azure.createBlobService('your-storage-account', 'your-storage-access-key');
    const containerUrl = blobService.getUrl(containerName);
    // Generate text-to-speech audio and stream it directly to a blob
    const text = 'Hello, world!';
    const stream = textToSpeech.synthesize(text, { format: 'audio/wav' });
    const blobName = 'your-blob-name.wav';
    const blobStream = blobService.createWriteStreamToBlockBlob(containerName, blobName, (err, result) => {
      if (err) {
      } else {
        console.log(`Blob ${blobName} saved to ${containerUrl}`);

    This code generates text-to-speech audio for the text "Hello, world!" and streams it directly to a blob named "your-blob-name.wav" in an Azure Blob Storage container named "your-container-name". The createWriteStreamToBlockBlob method creates a writable stream that writes data to a block blob in the specified container. The pipe method is used to pipe the text-to-speech audio stream to the blob stream.

    You can use this code in an app hosted on a third-party server or on Azure App Service. However, you will need to ensure that your app has the necessary permissions to access your Azure Blob Storage account.

    Please let me know if you have any questions, we are happy to help further.



    -Please kindly accept the answer and vote 'Yes' if you feel helpful to support the community, thanks a lot.

    0 comments No comments

  2. Steffen Schreiber 0 Reputation points

    Hello @YutongTie-MSFT

    thanks, this looks promising! As visemes are essential for me, I need to use the speakSsmlAsync function from microsoft-cognitiveservices-speech-sdk , which accepts a stream argument of type AudioOutputStream, PushAudioOutputStreamCallback or fs.PathLike. Could I use an AudioOutputStream to stream the data to the blob storage? How can I make an AudioOutputStream compatible with a BlockBlobClient from the @azure/storage-blob npm package?

    Regarding the azure-storage package for npm: This seems to be deprecated and the advice is to use @azure/storage-blob instead. I assume I need to create a BlockBlobClient from that library in order to achieve my goal, right?

    Best regards,

    0 comments No comments

  3. Steffen Schreiber 0 Reputation points

    Sorry, this was a double post, but I don't seem to be able to delete this.

    0 comments No comments