Punuru_BhanuPrasanth | 2023-09-16 03:21:16 UTC | #1
Hi I am trying to record audio and upload it to genesys
when i try to send blob file in formData i am getting 200Ok but audio is not getting reflected
based on this https://developer.genesys.cloud/forum/t/upload-prompt-audio/10851 link we need to record audio in wav format, I tried recording in wav format but still facing same issue
const handleStartRecording = () => { setBlobUrl("") console.log("entered start") navigator.mediaDevices.getUserMedia({ audio: {sampleRate:11025} }) .then((stream) => { mediaChunksRef.current = []; mediaRecorderRef.current = new MediaRecorder(stream,{audioBitsPerSecond: 16000}); //mediaRecorderRef.current.addEventListener('dataavailable', handleDataAvailable); mediaRecorderRef.current.ondataavailable = handleDataAvailable; let date,time mediaRecorderRef.current.onstart=()=>{ date = new Date() time = date.getTime() console.log(typeof(time)) setDuration(time) } mediaRecorderRef.current.onstop = handleRecordingStop; mediaRecorderRef.current.start(); setRecording(true); }) .catch((error) => { console.error('Error accessing microphone:', error); }); };
const handleRecordingStop = () => { if (mediaChunksRef.current.length > 0) { const audioBlob = new Blob(mediaChunksRef.current, { type: 'audio/wav' }); const downloadUrl = URL.createObjectURL(audioBlob); console.log(audioBlob.type) // Calculate duration using recorded start time and current time setBlobUrl(downloadUrl); } setRecording(false); };
how to upload the audio to genesys?
system | 2023-10-17 03:21:51 UTC | #2
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 22035