|
@ -187,12 +187,11 @@ def get_respeaker_device_id(): |
|
|
return device_id |
|
|
return device_id |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RESPEAKER_RATE = 16000 #rospy.get_param("/RESPEAKER_RATE") #16000 |
|
|
|
|
|
RESPEAKER_CHANNELS = rospy.get_param("/RESPEAKER_CHANNELS") # 6 must flash 6_channels_firmware.bin first |
|
|
|
|
|
RESPEAKER_WIDTH = rospy.get_param("/RESPEAKER_WIDTH") # 2 |
|
|
|
|
|
|
|
|
RESPEAKER_RATE = rospy.get_param("/RESPEAKER_RATE", 16000) |
|
|
|
|
|
RESPEAKER_CHANNELS = rospy.get_param("/RESPEAKER_CHANNELS", 6) # 6 must flash 6_channels_firmware.bin first |
|
|
|
|
|
RESPEAKER_WIDTH = rospy.get_param("/RESPEAKER_WIDTH", 2) |
|
|
RESPEAKER_INDEX = get_respeaker_device_id() |
|
|
RESPEAKER_INDEX = get_respeaker_device_id() |
|
|
CHUNK = rospy.get_param("/RESPEAKER_RATE") # 1024 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHUNK = rospy.get_param("/CHUNK", 1024) |
|
|
|
|
|
|
|
|
class Audio: |
|
|
class Audio: |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
@ -207,8 +206,9 @@ class Audio: |
|
|
|
|
|
|
|
|
def get_audio(self): |
|
|
def get_audio(self): |
|
|
recorded_frames = self.record_audio(self.chunk_size) # set param here chunk size |
|
|
recorded_frames = self.record_audio(self.chunk_size) # set param here chunk size |
|
|
# print(str(recorded_frames)) |
|
|
|
|
|
self.audio_data_pub.publish(recorded_frames) |
|
|
|
|
|
|
|
|
audio = MyAudioData() |
|
|
|
|
|
audio.data = np.array(recorded_frames, dtype=np.uint16) |
|
|
|
|
|
self.audio_data_pub.publish(audio) |
|
|
self.wav_list.append(recorded_frames) |
|
|
self.wav_list.append(recorded_frames) |
|
|
self.record_count += 1 |
|
|
self.record_count += 1 |
|
|
# Every 5 seconds for |
|
|
# Every 5 seconds for |
|
@ -256,15 +256,15 @@ class Audio: |
|
|
if respeaker.is_voice() == 1: |
|
|
if respeaker.is_voice() == 1: |
|
|
# wav_data = list of lists of bytes |
|
|
# wav_data = list of lists of bytes |
|
|
wav_data = self.get_audio() |
|
|
wav_data = self.get_audio() |
|
|
if (str(type(wav_data)) == "<class 'list'>"): |
|
|
|
|
|
# Maybe publish wav_data as ROS message? |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
# if (str(type(wav_data)) == "<class 'list'>"): |
|
|
|
|
|
# # Maybe publish wav_data as ROS message? |
|
|
|
|
|
# pass |
|
|
# publish_wav(wav_data) # lol |
|
|
# publish_wav(wav_data) # lol |
|
|
# Call of Utku's function |
|
|
# Call of Utku's function |
|
|
# asa_out = process_wav(wav_data, asa_params) |
|
|
# asa_out = process_wav(wav_data, asa_params) |
|
|
# Convert asa_out to ROS message |
|
|
# Convert asa_out to ROS message |
|
|
audio_count += 1 |
|
|
audio_count += 1 |
|
|
print(audio_count) |
|
|
|
|
|
|
|
|
print("Audio count: ", audio_count) |
|
|
except usb.core.USBError: |
|
|
except usb.core.USBError: |
|
|
print('Respeaker not on USB bus') |
|
|
print('Respeaker not on USB bus') |
|
|
|
|
|
|
|
|