예제 #1
0
speech = sp.string2pathlib('{}audiodata/python.wav'.format(sp_dir))
s, sr = sp.loadsound(speech, sr=sr)

#########################################################
# Let's add some white noise (10 SNR)
s_n = sp.augment.add_white_noise(s, sr=sr, snr=10)

##############################################################
# What does the noisy audio sound like?
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ipd.Audio(s_n, rate=sr)

##############################################################
# What does the noisy audio look like?
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sp.plotsound(s_n, sr=sr, feature_type='signal', subprocess=True)

##############################################################
# What does the clean audio sound like?
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ipd.Audio(s, rate=sr)

##############################################################
# What does the clean audio look like?
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sp.plotsound(s, sr=sr, feature_type='signal', subprocess=True)

#########################################################################
# Built-In Denoiser Functionality
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
예제 #2
0
import soundpy as sp

###########################################################################
# Create a Signal
# ^^^^^^^^^^^^^^^

########################################################################
# First let's set what sample rate we want to use
sr = 44100

#########################################################################
# Let's create a signal of 10 Hz
sig1_hz = 10
sig1, sr = sp.generate_sound(freq=sig1_hz, amplitude=0.4, sr=sr, dur_sec=1)
sp.plotsound(sig1,
             sr=sr,
             feature_type='signal',
             title='Signal: {} Hz'.format(sig1_hz))

#########################################################################
# Let's create a signal of 20 Hz
sig2_hz = 20
sig2, sr = sp.generate_sound(freq=sig2_hz, amplitude=0.4, sr=sr, dur_sec=1)
sp.plotsound(sig2,
             sr=sr,
             feature_type='signal',
             title='Signal: {} Hz'.format(sig2_hz))

###########################################################################
# Combine Signals
# ^^^^^^^^^^^^^^^
예제 #3
0
                                                 noise,
                                                 sr=sr,
                                                 snr=10,
                                                 total_len_sec=2,
                                                 pad_mainsound_sec=0.5)

##########################################################
# Hear and see the noisy speech
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ipd.Audio(noisy, rate=sr)

##########################################################
sp.plotsound(noisy,
             sr=sr,
             feature_type='signal',
             title='Noisy Speech',
             subprocess=True)

##########################################################
# Hear and see the clean speech
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s, sr = sp.loadsound(speech, sr=sr)
ipd.Audio(s, rate=sr)

##########################################################
sp.plotsound(s,
             sr=sr,
             feature_type='signal',
             title='Clean Speech',
             subprocess=True)
                                                    snr=5)
ipd.Audio(noisyspeech_5snr, rate=sr)

#########################################################
snr5

######################################################################
# Visualize the Audio Samples
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^

######################################################################
# See Clean Speech (raw signal)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sp.plotsound(speech_sample,
             feature_type='signal',
             sr=sr,
             title='Speech: ' + word.upper(),
             subprocess=True)

######################################################################
# See Clean Speech (stft)
# ~~~~~~~~~~~~~~~~~~~~~~~
sp.plotsound(speech_sample,
             feature_type='stft',
             sr=sr,
             title='Speech: ' + word.upper(),
             subprocess=True)

###################################################################### See Noise (raw signal)
# ~~~~~~~~~~~~~~~~~~~~~~
sp.plotsound(noise_sample,
##########################################################
# Speech sample:
speech = '{}audiodata/python.wav'.format(sp_dir)
speech = sp.utils.string2pathlib(speech)

################################################################
# Hear and see speech
# ~~~~~~~~~~~~~~~~~~~

sr = 44100
f, sr = sp.loadsound(speech, sr=sr)
ipd.Audio(f,rate=sr)

##########################################################
sp.plotsound(f, sr=sr, feature_type='stft', title='Female Speech "Python"')

##########################################################
# Change Speed
# ~~~~~~~~~~~~

##########################################################
# Let's increase the speed by 15%:

fast = sp.augment.speed_increase(f, sr=sr, perc = 0.15) 

##########################################################
ipd.Audio(fast,rate=sr)

##########################################################
sp.plotsound(fast, sr = sr, feature_type = 'stft', 
예제 #6
0
######################################################
# Speech and Noise SNR 20
# -----------------------
y_snr20, snr20 = sp.dsp.add_backgroundsound(y,
                                            white_noise,
                                            sr=sr,
                                            snr=20,
                                            random_seed=40)
# round the measured snr:
snr20 = int(round(snr20))
snr20

######################################################
sp.plotsound(y_snr20,
             sr=sr,
             feature_type='signal',
             title='Speech SNR {}'.format(snr20),
             subprocess=True)
ipd.Audio(y_snr20, rate=sr)

######################################################
# Speech and Noise SNR 5
# ----------------------
y_snr05, snr05 = sp.dsp.add_backgroundsound(y,
                                            white_noise,
                                            sr=sr,
                                            snr=5,
                                            random_seed=40)
# round the measured snr:
snr05 = int(round(snr05))
snr05
예제 #7
0
######################################################
# Speech and Noise SNR 20
# -----------------------
y_snr20, snr20 = sp.dsp.add_backgroundsound(y,
                                            white_noise,
                                            sr=sr,
                                            snr=20,
                                            random_seed=40)
# round the measured snr:
snr20 = int(round(snr20))
snr20

######################################################
sp.plotsound(y_snr20,
             sr=sr,
             feature_type='signal',
             title='Speech SNR {}'.format(snr20))
ipd.Audio(y_snr20, rate=sr)

######################################################
# Speech and Noise SNR 5
# ----------------------
y_snr05, snr05 = sp.dsp.add_backgroundsound(y,
                                            white_noise,
                                            sr=sr,
                                            snr=5,
                                            random_seed=40)
# round the measured snr:
snr05 = int(round(snr05))
snr05