HI all!
I want to play local audio files on misty via my python script. However, that is not possible, so I need to save the audio files first on the misty platform. That’s where I get stuck… Can someone please help me out? Thanks!!!
ip = "192.168.1.149"
#misty = mistyPy.Robot(ip)
volume = 100
engine = pyttsx3.init()
sentence = "This is an example"
engine.save_to_file(sentence, 'test2.mp3')
engine.runAndWait()
audioFile = "test2.mp3"
contents = []
with open(audioFile, 'rb') as fd:
contents = fd.read()
byteArrayString = str(list(contents))
#print(byteArrayString)
h = {'Content-Type': 'multipart/form-data'}
body = '{FilenameWithoutPath: test2.mp3,DataAsByteArrayString: '+byteArrayString+', ImmediatelyApply: true, OverwriteExisting: true }'
requests.post('http://'+ip+'/api/audio', headers=h, json={"FilenameWithoutPath": audioFile, "DataAsByteArrayString": byteArrayString})
requests.post('http://'+ip+'/api/audio/play',json={"fileName": audioFile, "volume": 100})
requests.post('http://'+ip+'/api/arms',json={"arm": "both", "position": -30, "velocity": 50})