zl程序教程

您现在的位置是:首页 >  其它

当前栏目

潜艇的主动声呐探测信号

信号 主动 探测
2023-09-11 14:15:20 时间

简 介: 本文利用时频联系分布算法对于来自于视频中的潜艇主动声呐探测声音信号进行分析,但仍然无法得到和主管听起来频率变化的结果。具体原因现在尚不明白。

关键词 潜艇声呐时频联合分布

信号来源
目 录
Contents
分析信号
读入显示信号
时频联合分析
分析总结
处理代码

 

§01 号来源


  段声音来自于西瓜视频中的 为什么直升机是潜艇的天敌?它如何反潜? 中给出的来自于 油管 给出的主动潜艇声呐音频,并且同时给出了下面的频谱联合分布的热力图分布。

▲ 图1.1 音频的包络线波形

▲ 图1.1 音频的包络线波形

  下面给出了该段音频信号在CSDN上的下载链接:

▲ 图1.2  潜艇主动声呐检测

▲ 图1.2 潜艇主动声呐检测

  那么,下面剩下一个问题,上面的这个声音视频联合分布对应的热力图究竟如何制作出来的呢?

 

§02 析信号


  面再AI Studio中对于上载的音频信号进行分析。

2.1 读入显示信号

  首先将存储音频文件上载到 AI Studio中,为了使用其中的pydub模块读入 MP3 数据文件,需要预先安装 pydub 软件模块。

2.1.1 读入显示代码

import sys,os,math,time
import matplotlib.pyplot as plt
from numpy import *
from scipy.io import wavfile

submp3 = '/home/aistudio/data/submarine.mp3'
subwav = '/home/aistudio/data/submarine.wav'

from pydub import AudioSegment
sound = AudioSegment.from_file(file=submp3)
left =  sound.split_to_mono()[0]
sample_rate = sound.frame_rate
sig = frombuffer(left._data, int16)

print("sample_rate: {}".format(sample_rate), "len(sig): {}".format(len(sig)))

plt.clf()
plt.figure(figsize=(10,6))
plt.plot(sig)
plt.xlabel("n")
plt.ylabel("wave")
plt.grid(True)
plt.tight_layout()
plt.savefig('/home/aistudio/stdout.jpg')
plt.show()

▲ 图2.1.1 音频文件波形

▲ 图2.1.1 音频文件波形

sample_rate: 44100
len(sig): 232448

2.2 时频联合分析

from scipy import signal

startid = 2
endid = 350
f,t,Sxx = signal.spectrogram(sig, fs=sample_rate,
                             nperseg=2048, noverlap=1024, nfft=8192)

thresh = 50
Sxx[where(Sxx > thresh)] = thresh

plt.clf()
plt.figure(figsize=(10,6))
plt.pcolormesh(t, f[startid:endid], Sxx[startid:endid, :])
plt.xlabel('Time(s)')
plt.ylabel('Frequency(Hz)')
plt.grid(True)
plt.tight_layout()
plt.savefig('/home/aistudio/stdout.jpg')
plt.show()

▲ 图2.2.1 声音的时频联合分布

▲ 图2.2.1 声音的时频联合分布

▲ 图2.2.2 声音的时频联合分布

▲ 图2.2.2 声音的时频联合分布

▲ 图2.2.3 声音的时频联合分布

▲ 图2.2.3 声音的时频联合分布

2.2.1 分析结果

  通过上面利用 scipy.signal中的spectrogram给出信号的视频联合分布结果来看,始终无法显示出在上面动图给出的原来视频中的频谱结构。

  另外从实际听觉上来看,的确可以听到一些频率的变化。但是从得到的视频联合分布的结果看不到这种变化。现在看起来极大可能性是上面给出计算结果出现了问题。

 

析总结 ※


  文利用时频联系分布算法对于来自于视频中的潜艇主动声呐探测声音信号进行分析,但仍然无法得到和主管听起来频率变化的结果。具体原因现在尚不明白。

3.1 处理代码

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TEST1.PY                     -- by Dr. ZhuoQing 2022-02-07
#
# Note:
#============================================================

from headm import *                 # =
from scipy.io import wavfile


submp3 = '/home/aistudio/data/submarine.mp3'
subwav = '/home/aistudio/data/submarine.wav'

#sample_rate,sig = wavfile.read(subwav)
#printt(sample_rate:, len(sig):)

from pydub import AudioSegment
sound = AudioSegment.from_file(file=submp3)
left =  sound.split_to_mono()[0]
sample_rate = sound.frame_rate
sig = frombuffer(left._data, int16)

printt(sample_rate:, len(sig):)

#------------------------------------------------------------


plt.clf()
plt.figure(figsize=(10,6))
plt.plot(sig)
plt.xlabel("n")
plt.ylabel("wave")
plt.grid(True)
plt.tight_layout()
plt.savefig('/home/aistudio/stdout.jpg')
plt.show()

#------------------------------------------------------------
from scipy import signal


startid = 5
endid = 350
f,t,Sxx = signal.spectrogram(sig, fs=sample_rate,
                             nperseg=4096, noverlap=4000, nfft=8192)

thresh = 20
Sxx[where(Sxx > thresh)] = thresh

plt.clf()
plt.figure(figsize=(10,6))
plt.pcolormesh(t, f[startid:endid], Sxx[startid:endid, :])
plt.xlabel('Time(s)')
plt.ylabel('Frequency(Hz)')
plt.grid(True)
plt.tight_layout()
plt.savefig('/home/aistudio/stdout.jpg')
plt.show()




#------------------------------------------------------------
#        END OF FILE : TEST1.PY
#============================================================


■ 相关文献链接:

● 相关图表链接: