I am trying to create a bird recognition application, so when I activate the recognition function, from the UI, I wish to be able to send it to the server in real-time for it to recognize the bird by its songs.
Now I can only send it after I stop the recording.
I haven’t been able to find any information online regarding this, or any work-around for it, yet.
Here is the recording function:
async function startRecording() {
try {
const perm = await Audio.requestPermissionsAsync();
if (perm.status === "granted") {
await Audio.setAudioModeAsync({
allowsRecordingIOS: true,
playsInSilentModeIOS: true
});
const recordingInstance = new Audio.Recording();
await recordingInstance.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY);
setRecording(recordingInstance);
recordingInstance.setOnRecordingStatusUpdate((status) => {
console.log("Base64 recording data:", status);
console.log("uri: ", recordingInstance.getURI());
});
await recordingInstance.startAsync();
}
} catch (err) {
console.error('Failed to start recording', err);
}
}
Has anyone done this before using expo? Any other suggestions are welcomed!
Thanks!
2
Answers
I managed to do it opening the file and sending chunked data with a socket. The main problem was making sure the data was sent correctly, if you want to use this please be patient with the audio recording, you need to wait a few seconds before sending it.
Sending data:
You can try websockets, it is used for real time server connection, without the need to call apis. You may find what you are looking for in this link
https://socket.io