Browse Source

importing DSP python script

pull/65/head
Hongyu Li 2 years ago
parent
commit
8d4bab2ea7
5 changed files with 30 additions and 9 deletions
  1. +1
    -1
      vz_acoustic_scene_analysis/CMakeLists.txt
  2. BIN
     
  3. BIN
     
  4. +21
    -8
      vz_acoustic_scene_analysis/scripts/stretch_audio.py
  5. +8
    -0
      vz_acoustic_scene_analysis/setup.py

+ 1
- 1
vz_acoustic_scene_analysis/CMakeLists.txt View File

@ -28,7 +28,7 @@ find_package(Boost REQUIRED COMPONENTS thread)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##

BIN
View File


BIN
View File


+ 21
- 8
vz_acoustic_scene_analysis/scripts/stretch_audio.py View File

@ -8,22 +8,31 @@ from sympy import re
import usb.core
import struct
import time
import sys
import os
import rospy
import pickle
from contextlib import contextmanager
import stretch_body.hello_utils as hu
hu.print_stretch_re_use()
from vz_acoustic_scene_analysis.msg import MyAudioData
from rospy.numpy_msg import numpy_msg
# Utku's script
# import segmentation as seg
import sys
sys.path.append('/home/hello-robot/vz_modules/NEU_VZ_ASA/MehrshadTesting/codes/A_CoughDetection/src')
import feature_class
import DSP
import NEU_VZ_ASA.MehrshadTesting.codes.A_CoughDetection.src.DSP as dsp
model_path = '/home/hello-robot/clone/Robot_Autonomous_Navigation/catkin_ws/src/stretch_ros/vz_acoustic_scene_analysis/models/'
cough_classifier_file = model_path + 'cough_classifier'
cough_classifier_scaler = model_path + 'cough_classification_scaler'
loaded_model = pickle.load(open(cough_classifier_file, 'rb'))
loaded_scaler = pickle.load(open(cough_classifier_scaler, 'rb'))
# model_loc = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# print(model_loc)
from models import cough_classifier, cough_classification_scaler
# Import Utku's script
# from vz_acoustic_scene_analysis.models import cough_classifier as classifier
# from vz_acoustic_scene_analysis.models import cough_classification_scaler as scaler
# what does this mean
@contextmanager
def ignore_stderr():
devnull = None
@ -206,7 +215,9 @@ class ROSInterface:
self.respeaker = Tuning()
# Publisher for Audio Data
self.audio_data_pub = rospy.Publisher("/wav_data", numpy_msg(MyAudioData), queue_size=10)
# Connect to Utku's code
# For Utku's code: float of cough probabilty from sample
self.cough_prob = 0
def get_audio(self):
recorded_frames = self.record_audio(self.chunk_size) # set param here chunk size
@ -271,6 +282,8 @@ class ROSInterface:
flat_list = [item for sublist in wav_data for item in sublist]
print(type(flat_list[0]))
# Call of Utku's function
self.cough_prob = dsp.classify_cough(flat_list, RESPEAKER_RATE)
print(self.cough_prob)
# asa_out = process_wav(wav_data, asa_params)
# Convert asa_out to ROS message
audio_count += 1

+ 8
- 0
vz_acoustic_scene_analysis/setup.py View File

@ -0,0 +1,8 @@
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['vz_acoustic_scene_analysis'],
package_dir={'': 'scripts'}
)
setup(**d)

Loading…
Cancel
Save