interstellar_ai/app/backend/voice_backend.ts

30 lines
No EOL
893 B
TypeScript

import axios from "axios";
class VoiceSend {
sendToVoiceRecognition(audio_data: Blob) {
console.log("sending recording...");
console.log(typeof (audio_data));
console.log(audio_data instanceof Blob);
const formdata = new FormData()
formdata.append("audio", audio_data)
formdata.append("option", "offline")
formdata.append("type", "basic")
const dataSend = { option:"offline", type:"basic",audio:audio_data }
axios.post("http://localhost:5000/interstellar_ai/api/voice_recognition", formdata)
.then((response) => {
console.log(response.data)
return response.data.response
})
.catch(error => {
console.log("Error calling API:", error)
postMessage({ status: 500 })
})
}
}
export default VoiceSend;