音乐声音开始的时间

huangapple go评论50阅读模式
英文:

Find the time the music sound starts

问题

我有这个声音文件,我想找到音乐开始的时间。我只能使用scipy模块。如何检测声音开始时的x轴时间?

下面是一个示例图形。具有较高振幅的信号显示了音乐开始的时间。

请注意,有时信号中会有噪音,这些噪音也可能具有高峰值。

import scipy
import numpy as np 
import matplotlib.pyplot as plt

# 创建单一信号

dt = 0.001
t = np.arange(0, 6, dt)

低频信号 = np.sin(2 + np.pi * 10 * t)

音乐频率信号 = 3.5 * np.sin(2 + np.pi * 25 * t)
组合信号 = np.concatenate([低频信号, 音乐频率信号])
plt.plot(组合信号)
plt.show()

音乐声音开始的时间

英文:

I have this sound file where I am looking for the time the music starts. I am limited to using only the scipy module. How do I detect the time on x axis when the sound starts?

An example figure is shown below. The Signal with higher magnitudes shows when the music.

Note sometimes there is noise in the signal which could also have high peaks.

import scipy
import numpy as np 
import matplotlib.pyplot as plt

#create single signal

dt = 0.001
t= np.arange(0,6,dt)

lowFreq =  np.sin(2+ np.pi*10*t)

musicFreq =  3.5*np.sin(2+np.pi*25*t)
combinedSignal = np.concatenate([lowFreq,musicFreq])
plt.plot(combinedSignal)
plt.show()

音乐声音开始的时间

答案1

得分: 1

我认为你可以通过只使用以下代码来获得声音开始的时间:

idx_start = np.where(combinedSignal > 1)[0][0]

这将返回信号幅度第一次大于1的索引。

英文:

I think you can get the time when the sound start by just using:

idx_start = np.where(combinedSignal > 1)[0][0]

This will return the first index where the magnitude of your signal is greater than 1.

huangapple
  • 本文由 发表于 2023年2月10日 16:52:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75408805.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定