dora-vad 0.3.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dora_vad/__init__.py +11 -0
- dora_vad/main.py +53 -0
- dora_vad-0.3.7.dist-info/METADATA +24 -0
- dora_vad-0.3.7.dist-info/RECORD +6 -0
- dora_vad-0.3.7.dist-info/WHEEL +4 -0
- dora_vad-0.3.7.dist-info/entry_points.txt +3 -0
dora_vad/__init__.py
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
# Define the path to the README file relative to the package directory
|
4
|
+
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md")
|
5
|
+
|
6
|
+
# Read the content of the README file
|
7
|
+
try:
|
8
|
+
with open(readme_path, "r", encoding="utf-8") as f:
|
9
|
+
__doc__ = f.read()
|
10
|
+
except FileNotFoundError:
|
11
|
+
__doc__ = "README file not found."
|
dora_vad/main.py
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
from dora import Node
|
2
|
+
import pyarrow as pa
|
3
|
+
import numpy as np
|
4
|
+
import os
|
5
|
+
from silero_vad import load_silero_vad, get_speech_timestamps
|
6
|
+
import torch
|
7
|
+
|
8
|
+
model = load_silero_vad()
|
9
|
+
MIN_SILENCE_DURATION_MS = int(os.getenv("MIN_SILENCE_DURATION_MS", "200"))
|
10
|
+
MIN_SPEECH_DURATION_MS = int(os.getenv("MIN_SPEECH_DURATION_MS", "1000"))
|
11
|
+
|
12
|
+
MIN_AUDIO_SAMPLING_DURAION_S = int(os.getenv("MAX_AUDIO_DURATION_S", "20"))
|
13
|
+
MAX_AUDIO_DURAION_S = int(os.getenv("MAX_AUDIO_DURATION_S", "75"))
|
14
|
+
|
15
|
+
|
16
|
+
def main():
|
17
|
+
node = Node()
|
18
|
+
last_audios = []
|
19
|
+
while True:
|
20
|
+
event = node.next()
|
21
|
+
if event is None:
|
22
|
+
break
|
23
|
+
if event["type"] == "INPUT" and event["id"] == "audio":
|
24
|
+
audio = event["value"].to_numpy()
|
25
|
+
last_audios += [audio]
|
26
|
+
last_audios = last_audios[-100:]
|
27
|
+
audio = np.concatenate(last_audios)
|
28
|
+
speech_timestamps = get_speech_timestamps(
|
29
|
+
torch.from_numpy(audio),
|
30
|
+
model,
|
31
|
+
threshold=0.2,
|
32
|
+
min_speech_duration_ms=MIN_SPEECH_DURATION_MS,
|
33
|
+
min_silence_duration_ms=MIN_SILENCE_DURATION_MS,
|
34
|
+
)
|
35
|
+
|
36
|
+
# Check ig there is timestamp
|
37
|
+
if (
|
38
|
+
len(speech_timestamps) > 0
|
39
|
+
and len(last_audios) > MIN_AUDIO_SAMPLING_DURAION_S
|
40
|
+
):
|
41
|
+
|
42
|
+
# Check if the audio is not cut at the end. And only return if there is a long time spent
|
43
|
+
if speech_timestamps[-1]["end"] == len(audio):
|
44
|
+
continue
|
45
|
+
else:
|
46
|
+
audio = audio[0 : speech_timestamps[-1]["end"]]
|
47
|
+
node.send_output("audio", pa.array(audio))
|
48
|
+
last_audios = [audio[speech_timestamps[-1]["end"] :]]
|
49
|
+
|
50
|
+
# If there is no sound for too long return the audio
|
51
|
+
elif len(last_audios) > 75:
|
52
|
+
node.send_output("audio", pa.array(audio))
|
53
|
+
last_audios = []
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: dora-vad
|
3
|
+
Version: 0.3.7
|
4
|
+
Summary: Dora Node for Text translating using Argostranslate
|
5
|
+
Author: Haixuan Xavier Tao
|
6
|
+
Author-email: tao.xavier@outlook.com
|
7
|
+
Requires-Python: >=3.7,<4.0
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Programming Language :: Python :: 3.7
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
16
|
+
Requires-Dist: dora-rs (>=0.3.6,<0.4.0)
|
17
|
+
Requires-Dist: numpy (<2.0.0)
|
18
|
+
Requires-Dist: silero-vad (>=5.1,<6.0)
|
19
|
+
Description-Content-Type: text/markdown
|
20
|
+
|
21
|
+
# Speech Activity Detection(VAD)
|
22
|
+
|
23
|
+
This is using Silero VAD.
|
24
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
dora_vad/__init__.py,sha256=Gy4qL4vCeTyA5HR1Yp3ioL4-ClJyW8oi_38CzMuMsBM,358
|
2
|
+
dora_vad/main.py,sha256=vCTRvRcn51P9gBznRaFNtdz1rSycQDag66bm9Eficzw,1948
|
3
|
+
dora_vad-0.3.7.dist-info/METADATA,sha256=c9fXyxbuHxeH96JrUa0xdKDnlYcpm-A8DV4P4qbPTik,818
|
4
|
+
dora_vad-0.3.7.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
5
|
+
dora_vad-0.3.7.dist-info/entry_points.txt,sha256=wr9gBgtZsPnfZYt4HJD6Pf7if_ieGubTZxuEbWbJmQI,47
|
6
|
+
dora_vad-0.3.7.dist-info/RECORD,,
|