Text to speech

免费增值
通过 kelvin | 已更新 vor 24 Tagen | Tools
人气

9.6 / 10

延迟

254ms

服务等级

100%

Health Check

N/A

返回所有讨论

how to download file

Rapid account: Mobbsteam
mobbsteam
vor 10 Monaten

I get content like this in the response
’��D�\x00\x12 \x04�\x01A\x18\x01\x07C�0Fo�\x07�\x06c���\x11��#��\x1B@\x19��;�0d~\x00\x07�\x18\x1F���y�\x0E��\x0F�y�?�\x11\x1C�\x01<\x00���:8fa�\b��\x03H\x01���3G\x05\x06c�^/���D�\n’ +
’\x111�D\x01�(\x00�\tt���n/.���b�\x0F|�k\x0F\x1CO��yX�)��[��;_������\x15\x1Ec�;�\x13\x01�cY���H\t�\x11�1�Y)�\x00�\x03�\x18au��y�Ps>\x1F��ۘ��D�\x18\x18qbL\x01�@\x00��Qtpq�X׹\x02gڟz�u#��!�\x151\x153�F(&\x11\x0F��k������\x04>��RE\x05B�oH\x1A\f\x0ER�\x100R\x13��1g(ͫ��\x13�`�W!X�ʪ���D�\t\x13�ʠ\x01�h\x00�\x03�����Pnݨ��؅�h���\x14�@���\t\x13\x01ʈs]52��o\x1E�5;��C��\t!���<��C�C���.��K����IR�\x0B \x12oD7h�7��D�\r\x15���\x01�8\x00\x1F\x0B\x1F:��RQ�#��緟mC�f��T��A9�Vx�i)\x12\t��v�\x144�P��(W���J��0V�8��;c��/��-��G������R�\x1C\x10��x��D�\t\x13�v�\x00�\x12����!�%�r\x14��AQs�!�\x16H�R�o��&�U毭�.����@��u\x1D����I�^��kk�%��\x0B,\x06&\x01��p�Yݺ��W�\x02�OZ�\x1D�����D�\r\x15q��\x00�V�\x00ca�93����a��d��c�2��\x1E�MMσ�\x1AhfYU��\x12�RF�����q���}D̽�Kϛ�xѠ�\x03\r@�\x11�������5vHH��\x0Fά��D�\n’

what is the format or type?

create a file and download to the root of the project on nodejs?

Rapid account: Mobbsteam
mobbsteam Commented vor 10 Monaten

Thank you for your reply! I have a node js application without an express server. Needed to make a request and get a file in the root of the project. Here is the code I needed.

const axios = require(‘axios’);
const fs = require(‘fs’);

axios({
method: ‘GET’,
url: ‘URL_request’,
responseType: ‘stream’
})
.then(response => {
const writer = fs.createWriteStream(‘file_name.mp3’);
response.data.pipe(writer);

writer.on('finish', () => {
  console.log('File successfully downloaded');
});

writer.on('error', err => {
  console.error('Error downloading the file:', err);
});

})
.catch(error => {
console.error(‘Error when executing the request:’, error);
});

Rapid account: Kelvin 2 Go
kelvin2go Commented vor 10 Monaten

the format is in ‘Content-Type’, ‘audio/mpeg’

If calling from browser this can directly play within chrome.
If you use in project like expressjs nodejs, you can do something like:

download mp3

const express = require('express');
const app = express();

app.get('/download', (req, res) => {
  // Simulated audio stream
  const audioStream = getAudioStreamFromEndpoint(); // Replace this with your endpoint to get the audio stream

  // Set the response headers
  res.set('Content-Type', 'audio/mpeg');
  res.set('Content-Disposition', 'attachment; filename="audio.mp3"');

  // Pipe the audio stream to the response
  audioStream.pipe(res);
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Or directly steam it

 app.get('/audio', (req, res) => {
  // Simulated audio stream
  const audioStream = getAudioStreamFromEndpoint(); // Replace this with your logic to get the audio stream

  // Set the response headers
  res.set('Content-Type', 'audio/mpeg');
  res.set('Content-Disposition', 'inline');

  // Send the audio stream
  audioStream.pipe(res);
});

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论