Javascript for playing audio from server - javascript

I have a database in MS SQL Server'08 with mp3 files as BLOB objects (I use filestream for storing).
There's a WCF service which works with database (linq).
There's a client application on html+javascript (and nothing more).
How to play one of the audio files from server on the client?I tried to send a byte array which represents mp3 file, but it's a problem how to play this array as sound using javascript.
Thanks

You need to use a server side script to serve up the MP3 out of the database.
If you are using SQL Server, I assume you will need to use the .Net Framework to fetch rows from the database.

Related

Can MQTT stream audio directly to a web client?

I was able to set up an Arduino to stream audio from a microphone into a linux server that's hosting an MQTT server. I then have a golang script that subscribes to the MQTT server, saves payload to disk as a binary file, and converts the binary file to a .WAV file with FFMPEG.
Is it possible to have a web browser use only client side code to subscribe to the same MQTT server, receive the audio payload from the Arduino, and stream the audio in near-real-time to the human listener's computer speakers? I see a Paho Javascript Client library that can help me connect to MQTT, but it seems to receive payloads as string, which isn't evident to me on how I'd stream audio content with. Hence, why I'm asking if it's even practical/feasible?
Or will I need to build another server-side script to stream MQTT data as audio data for a web client?
To ensure it works in all environments, ensure that you use MQTT over WebSocket to connect to the server.
Here is a discussion of this: Can a web browser use MQTT?
Look closer at the paho doc, there is a fiction to get the message payload as binary data using the message.payloadBytes field.
payloadBytes | ArrayBuffer | read only The payload as an ArrayBuffer
An example is described here:
https://www.hardill.me.uk/wordpress/2014/08/29/unpacking-binary-data-from-mqtt-in-javascript/
But basically you end up withan ArrayBuffer holding the binary data that you can then coonvert to a Typed Array and read back values at what ever offset you need.

Convert wav data to flac data using JS

I have a JS blob of WAV Data which I need to convert to FLAC data which I need to send an AJAX request to my localhost Django server where I want to use the Google Speech API.
The important thing here is that I don't want to store any kind of audio data anywhere on the server (So I think I should refrain from using commands which include "input.wav" and "output.flac")
I tried using pySoX but didn't know how to use without providing the paths of input and output files.
I am open to any other strategies as I don't know how this is done conventionally.

How can I play an mp3 clientside by getting it from the server?

The client sends a GET request to the server with the name of the audio file it wants. The server, which has access to the audio files, constructs a path to the mp3.
Right now I am calling result.sendFile('/audio/mysong.mp3') on the server, and getting the binary data on the client.
I haven't found a way to construct the mp3 object on the client to where I can just create a new Audio object and call .play(). Is there any way to do this?
Is there a better way to send the mp3 to the client?
Thanks

REST Api in node to send audio file along with json data

I have a REST API built using node and express. Now i need to send the following data in one http request:
jSON Data
One Audio File to be playable on client
On the client side,i have a simple audio player that requires audio file path as input to play the file. Now i don't understand the whole flow. How will i send the file from API and how the client consume it?
The file is located in file system of the server. Point me in the right direction !!
Express doesn't appear to support multipart responses. I'd instead recommend returning JSON that includes a URL to the audio file to play. Different routes on your Express server can send the JSON and the audio files. This approach will require two different HTTP requests from your client, but it will also be far more compatible with different browsers, since not all of them deal with HTTP multipart responses the same.
It is very different type of data you trying to deliver to client.
Much better and scalable will be to have two separate requests. One for JSON data that will contain details over where Audio is located (file name?). RESTful dont have to answer with only JSON or XML data, but it is highly recommended though.
Then another request to node, that will respond with streaming audio data, please check this good question and answers.
If you need just to send audio file without live streaming, then read this: Nodejs send file in response

Audio fingerprinting in javascript

I am trying to compare audio files at client side, I will not upload them on to the server, hence I want to get the fingerprint of the file even before uploading it to the server.
Do we have a library which can be hosted on our website
If No, Is it possible to do one , I am planning to
I have a song read from local system , I want to get its audio fingerprint so that I can compare with other audio file either on the server side or client side . I can send it to the server and get it done by methods already available in java or c# , but thats too much load to the bandwidth. So I wish to get the audio fingerprint at the client side itself using javascript .
I'm not exactly sure what you mean by "fingerprint" but if you just want to get metadata information you can check out this library: https://github.com/aadsm/JavaScript-ID3-Reader
I would recommend echoprint as it seems to be what your looking for.

Categories

Resources