interstellar_ai/app/backend/voice_backend.ts
2024-09-30 15:26:31 +02:00

19 lines
No EOL
603 B
TypeScript

import axios from "axios";
export const sendToVoiceRecognition = (audio_data: Blob): Promise<string> => {
console.log("sending recording...");
const formdata = new FormData()
formdata.append("audio", audio_data)
return 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 })
return "Error"
})
}