Vincent
Vincent

Reputation: 21

Accessing data from the NAO robot in python

Im trying to use a recorded audio file from NAO in python and turn it using speech recognition into text.

I looked in FileZilla and the audiofile is stored in /data/home/nao/record.wav on the Nao, but Im not able to access it in my python code. I tried to use ALMemoryProxy::getData("/data/home/nao/record.wav") but that did not work. Is there another way?

Upvotes: 1

Views: 151

Answers (1)

Vincent
Vincent

Reputation: 21

If anyone needs to do the same I used paramiko

import paramiko

host = 'IP of your NAO'
user = 'nao'
password = 'password of you NAO'
filename = 'name of the file you want to transfer'

try:
    transport = paramiko.Transport((host, 22))
    transport.connect(username=user, password=password)
    sftp = paramiko.SFTPClient.from_transport(transport)
    sftp.get(filename, filename)
    print("File downloaded successfully.")
except Exception as e:
    print("An error occurred:", e)
    # Additional error handling if needed
finally:
    sftp.close()
    transport.close()

Upvotes: 1

Related Questions