我想比较两个语音文件。第一个文件(ref)和比较文件(comp)分别由不同的人发音。我的假设是,语音相似度越接近,发音、语调、语气就会相同。然而,问题是这两个文件的长度不同。可以比较吗?
!pip install librosa # colab import numpy as np import matplotlib import matplotlib.pyplot as plt import librosa import librosa.display plt.figure(figsize=(10, 3)) x_1, fs_1 = librosa.load('voice_tar.wav') x_2, fs_2 = librosa.load('voice_comp.wav') print('<Voice_tar>', 'audio shape:', x_1.shape, 'length:', x_1.shape[0]/float(fs_1), 'secs') print('<Voice_comp>', 'audio shape:', x_2.shape, 'length:', x_2.shape[0]/float(fs_2), 'secs') fig, ax = plt.subplots(nrows=2, sharex=True, sharey=True) librosa.display.waveshow(x_1, sr=fs_1, ax=ax[0]) ax[0].set(title='Voice_tar') ax[0].label_outer() librosa.display.waveshow(x_2, sr=fs_2, ax=ax[1]) ax[1].set(title='Voice_comp')
结果如下。 音频形状:(43395,) 长度:1.9680272108843537 秒 音频形状:(31673,) 长度:1.4364172335600907 秒
这是 2 个语音文件的图像。 2 个语音文件的图像
并且,如何获得 ibrosa.segment.cross_similarity() 的相似性?
我也在研究这个问题;最好直接处理音频,但上面仍然没有解决方案,您可以尝试将其转换为具有图像问题的计算机视觉,如下
```py x, sr = librosa.load(duongdan)
if show: librosa.display.waveshow(y_ref, sr=sr1, alpha=0.4) plt.show()
fea = librosa.feature.spectral_centroid(y=x, sr=sr)[0] # or any feature you want frames = range(len(fea)) # Computing the time variable for visualization t = librosa.frames_to_time(frames) plt.plot(t, fea, color=’b’) ```