Good evening Stack Overflow! I really need help for a project of mine where I'm using sip.js and a VoIP to make real calls to a phone number.
The Goal
I want to allow the user to record the audio and microphone and save the data on a server (in base64 encoding or as a file). So I after the conversation can hear the conversation again and use it for what ever my purpose (employee training) was.
The Problem
I can't get the sound of the person speaking, which comes through and -HTML tag (working with the sip.js plugin). As of now I haven't found any way to successfully save the sound streaming through this audio tag.
What I've done so far
I've successfully figured out how to record the audio of the microphone using a plugin called AudioRecorder which allows me to record the audio through the microphone and saving it. I slightly changed the code so it got saved encoded as base64. This all work as expected, though I only get the audio of my own voice, and not the person I'm talking with.
Because I succeed to record the audio of my own voice I looked into the AudioRecorder plugin and tried to reverse the plugin to record from a audio tag. I found the "createMediaStreamSource" function inside AudioRecorder which I wanted to work with the -tag which did not work (as I suspected, because the -tag in it self isn't a stream (of which i understand).
The Code
I'm basically using the sip.js plugin to establish a call to a phone number by using below code (just using an example, matching my code, because my raw code contains some added values which doesn't need to be showed here):
// Create a user agent called bob, connect, and register to receive invitations.
var userAgent = new SIP.UA({
uri: '[email protected]',
wsServers: ['wss://sip-ws.example.com'],
register: true
});
var options = { media: { constraints: { audio: true, video: false }, render: { remote: document.getElementById("audio") } } };
Then i use the build in invite function to call a phonenumber, which does the rest. Audio and microphone is now up and running.
userAgent.invite("+4512345678", options);
I can now talk with my new best friend Bob. But I can't record other than my own sound as of now.
Whats Next?
I would really like some help to understand how I can record the sound of "Bob" and store it, preferred in the same file as my own voice. If I have to record two separately files and play them synced, I won't mind, but else if preferred.
I know this might just be a call for help without showing anything real code of what I've tried to do it myself, but I have to admit I just fiddled with the code for hours without any good results and now I'm screaming for help.
Thank your all in advance and sorry for the bad grammar and (mis)use of language.