26 from scipy.io
import wavfile
28 from rapp_platform_ros_communications.srv
import (
29 AudioProcessingDenoiseSrv,
30 AudioProcessingDenoiseSrvResponse,
32 AudioProcessingSetNoiseProfileSrv,
33 AudioProcessingSetNoiseProfileSrvResponse,
35 AudioProcessingDetectSilenceSrv,
36 AudioProcessingDetectSilenceSrvResponse,
38 AudioProcessingTransformAudioSrv,
39 AudioProcessingTransformAudioSrvResponse
42 from rapp_platform_ros_communications.msg
import (
46 from std_msgs.msg
import (
50 from rapp_detect_silence
import DetectSilence
51 from rapp_energy_denoise
import EnergyDenoise
52 from rapp_sox_denoise
import SoxDenoise
53 from rapp_utilities
import Utilities
54 from rapp_set_noise_profile
import SetNoiseProfile
55 from rapp_transform_audio
import TransformAudio
80 set_noise_profile_topic = \
81 rospy.get_param(
"rapp_audio_processing_set_noise_profile_topic")
83 rospy.get_param(
"rapp_audio_processing_denoise_topic")
84 energy_denoise_topic = \
85 rospy.get_param(
"rapp_audio_processing_energy_denoise_topic")
86 detect_silence_topic = \
87 rospy.get_param(
"rapp_audio_processing_detect_silence_topic")
88 transform_audio_topic = \
89 rospy.get_param(
"rapp_audio_processing_transform_audio_topic")
91 if(
not set_noise_profile_topic):
92 rospy.logerror(
"Audio processing noise profiling topic param not found")
93 if(
not denoise_topic):
94 rospy.logerror(
"Audio processing denoise topic param not found")
95 if(
not energy_denoise_topic):
96 rospy.logerror(
"Audio processing energy denoise topic param not found")
97 if(
not detect_silence_topic):
98 rospy.logerror(
"Audio processing detect silence topic param not found")
99 if(
not transform_audio_topic):
100 rospy.logerror(
"Audio processing noise transform audio topic param not found")
106 rospy.get_param(
"rapp_audio_processing_energy_denoising_debug")
113 set_noise_profile_service = rospy.Service(set_noise_profile_topic, \
116 denoise_service = rospy.Service( \
117 denoise_topic, AudioProcessingDenoiseSrv, \
120 energy_denoise_service = rospy.Service( \
121 energy_denoise_topic, AudioProcessingDenoiseSrv, \
124 detect_silence_service = rospy.Service( \
125 detect_silence_topic, AudioProcessingDetectSilenceSrv, \
128 transform_audio = rospy.Service( transform_audio_topic, \
138 res = AudioProcessingSetNoiseProfileSrvResponse()
141 ret = self._set_noise_profile_module.setNoise_profile(\
143 req.noise_audio_file,\
149 res.success =
'false'
159 res = AudioProcessingDenoiseSrvResponse()
160 res.success = self._sox_denoise_module.soxDenoise(\
164 req.denoised_audio_file,\
174 res = AudioProcessingDetectSilenceSrvResponse()
175 [res.level, res.silence] = self._detect_silence_module.detectSilence(\
176 req.audio_file, req.threshold)
177 if res.silence ==
True:
180 res.silence =
"false"
189 res = AudioProcessingDenoiseSrvResponse()
190 output = self._energy_denoise_module.energyDenoise(\
191 req.audio_file, req.scale, req.denoised_audio_file,\
196 res.success =
"false"
205 res = AudioProcessingTransformAudioSrvResponse()
207 [ res.error, res.fullpath ] = \
208 self._transform_audio_module.transform_audio( \
209 req.source_type, req.source_name, req.target_type, \
210 req.target_name, req.target_channels, req.target_rate )
215 if __name__ ==
"__main__":
216 rospy.init_node(
'AudioProcessing')
_set_noise_profile_module
Instantiates rapp_set_noise_profile.SetNoiseProfile.
Provides audio processing utilities.
_transform_audio_module
Instantiates rapp_transform_audio.TransformAudio.
_energy_denoising_debug
Energy denoising degug flag.
def transformAudioCallback
Service callback for Audio transformation.
def __init__
Constructor performing initializations.
_utilities_module
Instantiates rapp_utilities.Utilities.
_detect_silence_module
Instantiates rapp_detect_silence.DetectSilence.
def denoiseCallback
Service callback for denoising.
def detectSilenceCallback
Service callback for Detecting silence.
def energyDenoiseCallback
Service callback for Energy denoising.
_energy_denoise_module
Instantiates rapp_energy_denoise.EnergyDenoise.
def setNoiseProfileCallback
Service callback for setting noise profile.
_sox_denoise_module
Instantiates rapp_sox_denoise.SoxDenoise.