首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在音频文件中是否有快速找到(不一定识别)人类语音的方法?

问在音频文件中是否有快速找到(不一定识别)人类语音的方法?
EN

Stack Overflow用户
提问于 2015-09-15 19:42:17
回答 3查看 5.4K关注 0票数 13

我想写一个程序,自动同步取消同步字幕。我想出的解决方案之一就是用算法找到人类的语言,并将其调整到它的子项。我发现的API (Google,Yandex SpeechKit)与服务器一起工作(对我来说不太方便),并且(可能)做了很多不必要的工作来确定到底说了什么,而我只需要知道已经说了些什么。

换句话说,我想给它音频文件,并得到这样的东西:

代码语言:javascript
复制
[(00:12, 00:26), (01:45, 01:49) ... , (25:21, 26:11)]

是否有一种解决方案(最好在python中)只找到人工语音并在本地机器上运行?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-09-15 19:54:07

您想要做的事情的技术术语称为语音活动检测(VAD)。有一个名为长矛的python库可以完成它(除其他外)。

票数 7
EN

Stack Overflow用户

发布于 2016-04-24 16:59:14

温布洛瓦是谷歌出色的WebRTC语音活动检测( VAD )实现的一个Python包装器--它在我所使用的任何VAD中都做得最好,甚至在有噪音的音频中也是如此。

为了达到你的目的,你可以这样做:

  1. 转换文件为8 KHz或16 Khz,16位,单一格式.这是WebRTC代码所要求的。
  2. 创建一个VAD对象:vad = webrtcvad.Vad()
  3. 将音频分割成30毫秒的块。
  4. 检查每个块是否包含语音:vad.is_speech(chunk, sample_rate)

VAD输出可能是“噪音”,如果它将单个30毫秒的音频块归类为语音,那么您就不想为此输出时间。你可能想看看过去0.3秒左右的音频,看看在这段时间里30毫秒的大部分块是否被归类为语音。如果它们是,则输出0.3秒周期的起始时间作为言语的开始。然后你做一些类似的事情来检测演讲结束的时间:等待0.3秒的音频,其中30毫秒的大部分块不被VAD归类为语音--当这种情况发生时,输出结束时间作为语音的结尾。

为了达到你的目的,你可能需要稍微调整一下时间来获得好的效果--也许你决定你需要0.2秒的音频,其中超过30%的块在触发前被VAD分类为语音,而1.0秒的音频在你去触发之前将超过50%的块归类为非语音。

环形缓冲区(Python中的collections.deque)是跟踪最后N块音频及其分类的一种有用的数据结构。

票数 6
EN

Stack Overflow用户

发布于 2015-09-15 20:32:28

你可以在你的音频文件上运行一个窗口,并尝试提取出总信号中多少部分是人类的声频(基频在50到300赫兹之间)。以下是给出直觉,是未经测试的真实音频。

代码语言:javascript
复制
import scipy.fftpack as sf
import numpy as np
def hasHumanVoice(X, threshold, F_sample, Low_cutoff=50, High_cutoff= 300):
        """ Searching presence of frequencies on a real signal using FFT
        Inputs
        =======
        X: 1-D numpy array, the real time domain audio signal (single channel time series)
        Low_cutoff: float, frequency components below this frequency will not pass the filter (physical frequency in unit of Hz)
        High_cutoff: float, frequency components above this frequency will not pass the filter (physical frequency in unit of Hz)
        F_sample: float, the sampling frequency of the signal (physical frequency in unit of Hz)
        threshold: Has to be standardized once to say how much power must be there in real vocal signal frequencies.    
        """        

        M = X.size # let M be the length of the time series
        Spectrum = sf.rfft(X, n=M) 
        [Low_cutoff, High_cutoff, F_sample] = map(float, [Low_cutoff, High_cutoff, F_sample])

        #Convert cutoff frequencies into points on spectrum
        [Low_point, High_point] = map(lambda F: F/F_sample * M, [Low_cutoff, High_cutoff])

        totalPower = np.sum(Spectrum)
        fractionPowerInSignal = np.sum(Spectrum[Low_point : High_point])/totalPower # Calculating fraction of power in these frequencies

        if fractionPowerInSignal > threshold:
            return 1
        else:
            return 0

voiceVector = []
for window in fullAudio: # Run a window of appropriate length across the audio file
    voiceVector.append (hasHumanVoice( window, threshold, samplingRate)
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32594316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档