Hello @Steffen Schreiber
Thanks for reaching out to us, based on my personal experience, you may want to try createWriteStreamToBlockBlob
method.
Reference - [http://azure.github.io/azure-storage-node/BlobService.html#createWriteStreamToBlockBlob__anchor]
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) {
console.error(err);
} else {
console.log(`Blob ${blobName} saved to ${containerUrl}`);
}
});
stream.pipe(blobStream);
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.
Regards,
Yutong
-Please kindly accept the answer and vote 'Yes' if you feel helpful to support the community, thanks a lot.