Ritu Singh
Problem:
I'm trying to send gtts generated audio file from Django to Vue via HttpResponse.
Django's views.py:
and when vue receives the response data, it is like the below:
I guess it is because the bytes have been converted to string over the transfer and I have to convert it back to the audio file. But no matter whether using blob or other suggested methods, I could not convert it to an mp3 file to be played in javascript.
How could I achieve this?
Solution:
There are multiple ways to play audio in the browser, so it really depends on how you mean to play your audio file.
creating <audio> element
using Audio() constructor
converting binary data (Axios)
converting binary data (Fetch API)
Hopefully one of these methods helps.
Suggested blogs:
>How to solve the issue of producing the wrong output value in PHP?
>How to solve XGBoost model training fails in Python
>How to Upload files and JSON data in the same request with Angular?
>How to fix when Postgres connection refused while running laravel tests on gitlab CI?
>Changing main page as Identity's Login page in ASP.NET Core 7
>How can I get the original type of a Mock after the Mock has been cast to an object