You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Play the audio locally before sending data to the server
Send audio file to the server
Here's the current code:
In service
startRecording = ()=> {
try {
return VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {
if (result.value) {
return VoiceRecorder.startRecording()
} else {
return Promise.reject('Permission denied');
}
})
} catch (error) {
console.log(error);
return Promise.reject(error);
}
}
stopRecording = async () => {
console.log("stopRecording");
let result = await VoiceRecorder.stopRecording();
let blob = base64StringToBlob(result.value.recordDataBase64, result.value.mimeType);
let data_text = await blob.text();
let extension = mime.getExtension(result.value.mimeType);
let write_result = await Filesystem.writeFile({
path: `temp.${extension}`,
data: data_text,
directory: Directory.External,
encoding: Encoding.UTF8,
});
let uri = write_result.uri;
return uri;
}
At this point I tested the locally stored file temp.aac. Sent the file to PC and tried to playback the audio but audio player gives corrupted or codec error (note tried multiple audio players). While .aac file downloaded from the internet works absolutely fine.
What have I tried till now:
Tried storing data as shown above
Tried forcing the extension to be .aac instead of .adts that mime.getExtension suggests
I am trying to utilize this library to:
Here's the current code:
In service
At this point I tested the locally stored file
temp.aac
. Sent the file to PC and tried to playback the audio but audio player gives corrupted or codec error (note tried multiple audio players). While.aac
file downloaded from the internet works absolutely fine.What have I tried till now:
.aac
instead of.adts
thatmime.getExtension
suggestsdata:${result.value.mimeType};base64,${result.value.recordDataBase64}
None of these have worked. Any suggestions would be appreciated.
PS: Maybe we need to encode the raw data before storing it to a file. Ref - https://stackoverflow.com/a/18970406/3955513
The text was updated successfully, but these errors were encountered: