interstellar_ai/app/backend/voice_backend.ts

17 lines
523 B
TypeScript
Raw Normal View History

2024-09-25 12:33:52 +02:00
import axios from "axios";
2024-09-30 12:45:19 +02:00
export const sendToVoiceRecognition = (audio_data: Blob): Promise<string> => {
2024-09-26 09:37:33 +02:00
2024-09-30 12:45:19 +02:00
const formdata = new FormData()
formdata.append("audio", audio_data)
2024-09-26 09:46:32 +02:00
2024-09-30 12:45:19 +02:00
return axios.post("http://localhost:5000/interstellar_ai/api/voice_recognition", formdata)
.then((response) => {
return response.data.response
})
.catch(error => {
console.log("Error calling API:", error)
postMessage({ status: 500 })
return "Error"
})
}