L
L
LakeForest2021-05-26 21:13:42
Flask
LakeForest, 2021-05-26 21:13:42

Sending a request from Vue to Flask to get an audio recording from the send_from_directory() method. How do I embed audio on Vue with Flask?

Sending a request from Vue to Flask for an audio recording. Audio comes to postman, and string comes to Vue. How do I embed audio on Vue with Flask?
Return audio from the Flask server.

return send_from_directory('./static/wavs/', wav_name,
                                   mimetype='audio/wav',
                                   as_attachment=False)

I want to insert audio into the front code written in Vue:
<div class="d-flex align-items-center">
        <audio>
          <source :src="response" type="audio/wav">
        </audio>
      </div>

But it returns text like this... What should I do with it?
UklGRiSGAABXQVZFZm10IBAAFFAABAAEAIlYAAESsAAACABAAZGF0YQCGAADFAaQAOv9UAQ0C1f4q

Server request:
axios('http://' + 'localhost:5000' + '/sinth', {
        method: "POST",
        headers: {
          "Accept": "application/json",
          "Content-Type": "application/json",
        },
        data: data
      })
          .then((response) => {
            this.response = response;
            this.show_response = true;
            this.spinner_visible = false;
            return response;
          })
          .catch((error) => {
            console.log(error);
            this.spinner_visible = false;
          });

If it is necessary to return otherwise, is it then possible to return the response in json with an audio file?
I would also like to return the text sent and processed by the server to the front, and not just the audio recording ...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question