I am posting a document with title and details. An audio is recorded as well.
Speech to text recognizes the voice and types out document. Title and Details are saved as a document. I want to save recorded audio as well, so that when i view the document i can play audio as well
How to post that audio?
With document?
or
Create another post/get to store the audio separately?
You can simply read the bytes of the audio file as a byte stream into a byte array with a file reader. To relate the audio file to the document, let the file point to the unique id/title of that document in the database. Here is an example with a JSON to post for storage:
{
"audioBytes": [5ghcj66g6yf...],
"documentId": "cchghh-g6y56g..."
}
Related
Similar to the Pure Data example here (https://www.youtube.com/watch?v=FLK854QyjE4) I'm trying to conceptualise how a file, such as a text file, might be read in Javascript and played back as glitch audio with the web audio api.
What I've tried so far:
A text string to base64 string appended with data:audio/mp3;base64, - results in "No video with supported format and MIME type found".
Text to binary with audio headers added - just does nothing.
How would I go about this?
I'm using jquery.voice.min.js and recorderWorker.js/recorder.js for to record audio with html5. At the moment I get to record audio and i get to url download html5 audio.
I want to save blob/audio html5 in my file system, but i dont know how.
When I get the url with audio i use this c How to ode, but i dont want to donwload audio, only want to save that blob audio in file system. How I can treat blob file for it?
$.voice.export(function(url){
console.log(url); // blob:http://vshaker.com/934a8934-e11a-4049-b133-fcec8e240b29
}, "URL");
Any clue, any idea?
Regards!
Just replace the URL with base64 and you will get a base64 string of the corresponding audio.
$.voice.export(function(url){
console.log(url); // blob:http://vshaker.com/934a8934-e11a-4049-b133-fcec8e240b29
}, "base64");
post the base64data to server.
create the audio file using any of the server side language and keep any where in the file system. update the new web path to the audio source.
I am making a browser based audio player. So for making a playlist from the local directory I am using :
<input type="file" id="getFile" />
Then I am using a button to confirm the playlist.On clicking the button I am calling a javascript function to change the src of the audio tag to play the new audio file selected in the playlist. I want the exact path of the file from the input file to run in the HTML5 audio player but it starts taking the path as C://Fakepath/filename.mp3. Can someone help me with this.
This is a security feature, by design. You should not be able to read the original file path of a file input into a browser form. File input is for reading file contents only, not metadata like path on the user's file system.
The good news is that you don't need the original file path. You can use FileReader's readAsDataURL to convert the file contents into a base64-encoded data URL and use that as the audio src. To read from #myUploadInput and output through #myAudioElement (also available as a working fiddle):
var reader = new FileReader();
reader.onload = function (event) {
document.getElementById("myAudioElement").src = event.target.result;
};
reader.readAsDataURL(document.getElementById("myUploadInput").files[0]);
if the user is 'building' / creating the playlist based on files they have locally you could do a 'browse' field (s) where they select the local audio files, then take the contents of the field (that Should include the paths to those images), build an array of the count/id, filename.mp3, and path... then, based on what is 'chosen' to play, just reassemble the full local path and play that file.
that would be an approach I would take anyway to see if it would work. the necessary piece here is getting the user to disclose the paths to the audio files... but Im still not 100% sure it would work given the security feature that the earlier commenter posted a link to.
if this were included in an application the user approved for local installation you could just refer to it using the 'application directory' and copy the file to that 'safe location' but since its web based it just really opens up a whole can of worms in terms of a potentially unapproved / authorized web function knowing your local directory structure. good luck, let me know if you find a solution.
While using HTML5 audio tag, i am having a problem.
I am using icecast2 server to stream my music.
But the problem is, browser saves the buffer when stream is played. So when the player is paused or the page is refreshed, instead of asking server for the fresh stream, it plays the previously saved buffer only.
As i am playing live stream, i want always fresh stream to be played. What can i do to ensure that??
What i found after browsing is- HTML5 Video: Force abort of buffering
So creating a new audio tag is an option but i am not clear on it and also i dont know if it is a good way.
Probably the most common way to prevent caching of any HTTP resource (text files, images, audio, etc) is to append a meaningless random GET parameter onto the URL. So if your URL is like this:
http://musicserver.com/livestream.mp3
Then you'd do something like this:
http://musicserver.com/livestream.mp3?nocache=12034981237
Where the value of nocache is randomly generated each and every time. Then the browser will treat it as a new unique resource/file.
I am looking for a solution just to show in a html page the name of each song when played from a mp3 player.
I just have a .txt file outputted from a software that fetches in real time each song artist and name from the mp3 tag, when a new song is being played, with this format inside (the .txt file is also autoupdated each time, like a log file does):
[DAY-MONTH-YEAR HOUR:MIN:SEC] * Artist - Track
Example:
[24-07-2010 20:17:11] * Song 1
[24-07-2010 20:21:11] * Song 2
[24-07-2010 20:25:18] * Song 3
[24-07-2010 20:29:58] * Song ...
I need to get this data from the .txt file and put it into a html div, showing the new song name when it has been logged into the file until a new song is played.
Pretty simple I think, but I donĀ“t know how to work with this formatted text file (it cannot be changed), instead a typical XML file.
I have founded a script that works with XML (not plain text) and the behavior is other than I expect, because it rotates the messages each 5 seconds, not just when the new song is playing:
http://www.dynamicdrive.com/dynamicindex2/ajaxticker.htm
How can I get the [DAY-MONTH-YEAR HOUR:MIN:SEC] * formatted items in javascript?
How can I update the html div, each time a new item (song) is loaded in the .txt file?
Thanks in advance for your help.
There are several pieces of your architecture missing, which makes it difficult to answer your question.
Where did the javascript page come
from?
What is the connection to the server
that the javascript comes from and
the mp3 player?
Where is the text file, on a server
or updated on the local computer by
the mp3 player?
But, if I make several assumptions you might get on the more correct path.
First, if the mp3 player sends a message to a server, and the server updates the text file (big assumption) then what you can do it to either have the javascript application poll the server on some timed basis, to decide when the song changes, and the server can just return the current song.
Is there is reason the javascript application needs the entire text file?
The other option is to have the server open up a long-term connection, such as comet (http://en.wikipedia.org/wiki/Comet_%28programming%29), and the server can just push the data to the javascript application.
I am not answering your question about how to parse the formatted file, as I don't see yet that that would actually be useful to your problem, but as I mentioned, there are too many unknowns in your question.