'
Zholud L.I., Shevaldysheva E.Z.
IMPLEMENTATION OF THE SEGMENTATION METHOD BY FITTING SIGNAL SHAPE IN PYTHON *
Аннотация:
the algorithm for signal segmentation using shape fitting is explored and implemented as code in the Python software product
Ключевые слова:
signal segmentation, shape similarity, librosa library, matplotlib library, audio analysis, signal shaping
УДК 004
Zholud L.I.
Postgraduate student at the Department of Electronic Computing Systems
Belarusian State University of Informatics and Radioelectronics
(Minsk, Belarus)
Shevaldysheva E.Z.
Candidate of Science, Philology, Associate Professor of the
Department of Intercultural Professional Communications
Belarusian State University of Informatics and Radioelectronics
(Minsk, Belarus)
IMPLEMENTATION OF THE SEGMENTATION
METHOD BY FIING SIGNAL SHAPE IN PYTHON
Abstract: the algorithm for signal segmentation using shape fitting is explored and implemented as code in the Python software product.
Keywords: signal segmentation, shape similarity, librosa library, matplotlib library, audio analysis, signal shaping.
The method of signal shape fitting segmentation is used to divide time series into separate segments based on the similarity of the signal shape. This method is based on the assumption that each segment has a unique signal shape that can be used for identification and extraction.
The segmentation process starts with defining the base signal shapes for each class of objects. Then, the algorithm computes the similarity of the signal shape throughout the time series and separates it into individual segments based on the minimal distance between the signal shapes.
Algorithm:
One example of applying this method is the segmentation of speech signals for speech recognition. In this case, the base signal shapes can be defined for different phonemes, and the algorithm can be used to automatically extract each phoneme from the speech stream.
However, the signal shape fitting segmentation method can be sensitive to noise and distortion in the signal, so additional data processing is required to address these issues.
To implement the signal shape fitting segmentation method in Python, you can use the librosa library for audio analysis and matplotlib for visualization. The code is provided below:
import librosa
import numpy as np
import matplotlib.pyplot as plt
def shape_fitting_segmentation(audio_path, threshold):
# Load audio
signal, sr = librosa.load(audio_path)
# Compute audio features
features = compute_features(signal, sr)
# Segment audio into similar shape segments
segments = []
current_segment = []
for i, feature in enumerate(features):
if feature > threshold:
current_segment.append(i)
else:
if current_segment:
segments.append(current_segment)
current_segment = []
if current_segment:
segments.append(current_segment)
return segments
# Function to compute audio features
def compute_features(signal, sr):
# For example, you can use librosa to compute spectral features
spectogram = np.abs(librosa.stft(signal))
spectogram = librosa.amplitude_to_db(spectogram, ref=np.max)
return spectrogram
# Example usage
audio_path = "proba.wav" # Path to audio signal file
threshold = 0.5 # Threshold value for shape similarity of segments
segments = shape_fitting_segmentation(audio_path, threshold)
# Plotting audio with segmentation
signal, sr = librosa.load(audio_path)
plt.figure(figsize=(14, 5))
librosa.display.waveplot(signal, sr)
for segment in segments:
start = segment[0]
end = segment[-1]
plt.axvspan(start, end, alpha=0.5, color='red')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.title('Audio Signal with Segmentation')
plt.show()
In this code, the shape_fitting_segmentation function takes the path to an audio file and a threshold value for segment shape similarity. It returns a list of segments, where each segment is represented by the indices of the temporal samples of the signal. Then, using librosa, the audio is loaded and the segments are marked on the signal plot using matplotlib.
СПИСОК ЛИТЕРАТУРЫ:
RESEARCH OF METHODS OF VOICE SIGNAL SEGMENTATION" [Online]. URL: https://libeldoc.bsuir.by/bitstream/123456789/48084/1/Pasternak_Issledovaniye.pdf (accessed: 27.09.23)
Номер журнала Вестник науки №12 (69) том 1
Ссылка для цитирования:
Zholud L.I., Shevaldysheva E.Z. IMPLEMENTATION OF THE SEGMENTATION METHOD BY FITTING SIGNAL SHAPE IN PYTHON // Вестник науки №12 (69) том 1. С. 796 - 799. 2023 г. ISSN 2712-8849 // Электронный ресурс: https://www.вестник-науки.рф/article/11303 (дата обращения: 19.05.2024 г.)
Вестник науки СМИ ЭЛ № ФС 77 - 84401 © 2023. 16+
*