Browse Source

Fixed chunk in param

pull/65/head
Hongyu Li 2 years ago
parent
commit
9556cd6917
4 changed files with 14 additions and 15 deletions
  1. +0
    -0
      vz_acoustic_scene_analysis/config/audio_params.yaml
  2. +2
    -2
      vz_acoustic_scene_analysis/launch/wav_audio.launch
  3. +1
    -1
      vz_acoustic_scene_analysis/msg/MyAudioData.msg
  4. +11
    -11
      vz_acoustic_scene_analysis/scripts/stretch_audio.py

+ 0
- 0
vz_acoustic_scene_analysis/config/audio_params.yaml View File

@ -1,4 +1,3 @@
TIMEOUT: 100000
VENDOR_ID: 0x2886
PRODUCT_ID: 0x0018

+ 2
- 2
vz_acoustic_scene_analysis/launch/wav_audio.launch View File

@ -1,4 +1,4 @@
<launch>
<node name="stretch_audio" pkg="vz_acoustic_scene_analysis" type="stretch_audio.py" />
<rosparam file="$(find vz_acoustic_scene_analysis)/config/audio_params.yaml" />
<rosparam command="load" file="$(find vz_acoustic_scene_analysis)/config/audio_params.yaml" />
<node name="stretch_audio" pkg="vz_acoustic_scene_analysis" type="stretch_audio.py" output="screen" />
</launch>

+ 1
- 1
vz_acoustic_scene_analysis/msg/MyAudioData.msg View File

@ -1 +1 @@
string[] data
uint16[] data

+ 11
- 11
vz_acoustic_scene_analysis/scripts/stretch_audio.py View File

@ -187,12 +187,11 @@ def get_respeaker_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()
CHUNK = rospy.get_param("/RESPEAKER_RATE") # 1024
CHUNK = rospy.get_param("/CHUNK", 1024)
class Audio:
def __init__(self):
@ -207,8 +206,9 @@ class Audio:
def get_audio(self):
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.record_count += 1
# Every 5 seconds for
@ -256,15 +256,15 @@ class Audio:
if respeaker.is_voice() == 1:
# wav_data = list of lists of bytes
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
# Call of Utku's function
# asa_out = process_wav(wav_data, asa_params)
# Convert asa_out to ROS message
audio_count += 1
print(audio_count)
print("Audio count: ", audio_count)
except usb.core.USBError:
print('Respeaker not on USB bus')

Loading…
Cancel
Save