Im trying to call python script through the local api (the api was setup through Flask). Inside unreal engine, I created blueprint to record audio when I press 2 and save inside content folder. All I need is how to send recorded audio to that flask api via VaRest and get back response audio to play. I saw lots of tutorial and couldn’t get how to do it. Actually it calls the api link when I release 2 but there is no audio sent via api as python gives error 400. I don’t know which node to connect with which node to send the audio. I’m relatively new to unreal engine, please help me to make this work.
This is the code I used to test api and it retrieves the response audio as expected
import requests
# Define the URL and file path
url = "http://127.0.0.1:5000/process_audio"
file_path = "second.wav"
# Send the audio file to the Flask API
with open(file_path, "rb") as audio_file:
files = {"audio": audio_file}
response = requests.post(url, files=files)
# Check if the response was successful
if response.status_code == 200:
# Save the response as an MP3 file
with open("response.mp3", "wb") as f:
f.write(response.content)
print("Audio response saved as 'response.mp3'.")
else:
print("Request failed with status:", response.status_code)
print("Response text:", response.text)
And this is when I tried to recreate the above mechanism in blueprint
It actually call API, but the audio is never sent. I getting error like error:400 (bad request) from flask. I searched turorials, forums and couldn’t find anything related to this. Anyone know how to send audio file via VaRest please help me .