跳转到主要内容

Home Assistant的意图

项目描述

Energy VAD

无外部依赖的简单基于能量的语音活动检测器(VAD)。

能量阈值从初始音频中校准,或可手动设置。

安装

pip install energy-vad

示例

import wave
from energy_vad import EnergyVad

vad = EnergyVad()

with wave.open("test.wav", "rb") as wav_file:
    assert wav_file.getframerate() == 16000
    assert wav_file.getsampwidth() == 2
    assert wav_file.getnchannels() == 1
    
    chunk = wav_file.readframes(vad.samples_per_chunk)
    while len(chunk) == vad.bytes_per_chunk:
        result = vad.process_chunk(chunk)
        if result is None:
            # calibrating
            pass
        elif result:
            # speech
            print("!", end="")
        else:
            # silence
            print(".", end="")

        chunk = wav_file.readframes(vad.samples_per_chunk)
        
print("")
print("Energy threshold:", vad.threshold)

# Clear calibrated threshold
vad.reset_calibration()

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分布

energy_vad-1.0.0.tar.gz (4.1 kB 查看哈希)

上传时间

构建分布

energy_vad-1.0.0-py3-none-any.whl (3.9 kB 查看哈希)

上传时间 Python 3

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面