2024-09-25 12:33:52 +02:00
|
|
|
import axios from "axios";
|
|
|
|
|
2024-09-26 09:37:33 +02:00
|
|
|
|
2024-09-25 12:33:52 +02:00
|
|
|
class VoiceSend {
|
2024-09-26 08:57:28 +02:00
|
|
|
sendToVoiceRecognition(audio_data: Blob) {
|
|
|
|
console.log("sending recording...");
|
2024-09-26 09:46:32 +02:00
|
|
|
|
|
|
|
const formdata = new FormData()
|
|
|
|
formdata.append("audio", audio_data)
|
|
|
|
|
|
|
|
const dataSend = { option:"offline", type:"basic",audio:audio_data }
|
|
|
|
axios.post("http://localhost:5000/interstellar_ai/api/voice_recognition", formdata)
|
2024-09-26 09:37:33 +02:00
|
|
|
.then((response) => {
|
|
|
|
console.log(response.data)
|
|
|
|
return response.data.response
|
2024-09-25 12:33:52 +02:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log("Error calling API:", error)
|
|
|
|
postMessage({ status: 500 })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default VoiceSend;
|