dora-microphone 0.3.7rc2__py3-none-any.whl → 0.3.9__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.
@@ -5,7 +5,7 @@ readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.m
5
5
 
6
6
  # Read the content of the README file
7
7
  try:
8
- with open(readme_path, "r", encoding="utf-8") as f:
8
+ with open(readme_path, encoding="utf-8") as f:
9
9
  __doc__ = f.read()
10
10
  except FileNotFoundError:
11
11
  __doc__ = "README file not found."
dora_microphone/main.py CHANGED
@@ -1,9 +1,9 @@
1
- import sounddevice as sd
2
- import numpy as np
3
- import pyarrow as pa
4
- import time as tm
5
1
  import os
2
+ import time as tm
6
3
 
4
+ import numpy as np
5
+ import pyarrow as pa
6
+ import sounddevice as sd
7
7
  from dora import Node
8
8
 
9
9
  MAX_DURATION = float(os.getenv("MAX_DURATION", "0.1"))
@@ -16,13 +16,18 @@ def main():
16
16
  start_recording_time = tm.time()
17
17
  node = Node()
18
18
 
19
- # pylint: disable=unused-argument
19
+ always_none = node.next(timeout=0.001) is None
20
+ finished = False
21
+
20
22
  def callback(indata, frames, time, status):
21
- nonlocal buffer, node, start_recording_time
23
+ nonlocal buffer, node, start_recording_time, finished
22
24
 
23
25
  if tm.time() - start_recording_time > MAX_DURATION:
24
26
  audio_data = np.array(buffer).ravel().astype(np.float32) / 32768.0
25
27
  node.send_output("audio", pa.array(audio_data))
28
+ if not always_none:
29
+ event = node.next(timeout=0.001)
30
+ finished = event is None
26
31
  buffer = []
27
32
  start_recording_time = tm.time()
28
33
  else:
@@ -30,7 +35,7 @@ def main():
30
35
 
31
36
  # Start recording
32
37
  with sd.InputStream(
33
- callback=callback, dtype=np.int16, channels=1, samplerate=SAMPLE_RATE
38
+ callback=callback, dtype=np.int16, channels=1, samplerate=SAMPLE_RATE,
34
39
  ):
35
- while True:
36
- sd.sleep(int(100 * 1000))
40
+ while not finished:
41
+ sd.sleep(1000)
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.2
2
+ Name: dora-microphone
3
+ Version: 0.3.9
4
+ Summary: Dora dora-microphone
5
+ Author-email: Haixuan Xavier Tao <tao.xavier@outlook.com>, Enzo Le Van <dev@enzo-le-van.fr>
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: dora-rs>=0.3.6
10
+ Requires-Dist: numpy<2.0.0
11
+ Requires-Dist: pyarrow>=5.0.0
12
+ Requires-Dist: sounddevice>=0.4.6
13
+
14
+ # Collect data from microphone
15
+
16
+ This node will send data as soon as the microphone volume is higher than a threshold.
17
+
18
+ This is using python Sounddevice.
19
+
20
+ It detects beginning and ending of voice activity within a stream of audio and returns the parts that contains activity.
21
+
22
+ There's a maximum amount of voice duration, to avoid having no input for too long.
23
+
24
+ ## Input/Output Specification
25
+
26
+ - inputs:
27
+ - tick: This is used to detect when the dataflow is finished.
28
+ - outputs:
29
+ - audio: 16kHz sampled audio sent by chunk
30
+
31
+ ## YAML Specification
32
+
33
+ ```yaml
34
+ - id: dora-vad
35
+ description: Voice activity detection. See; <a href='https://github.com/snakers4/silero-vad'>sidero</a>
36
+ build: pip install dora-vad
37
+ path: dora-vad
38
+ inputs:
39
+ audio: dora-microphone/audio
40
+ outputs:
41
+ - audio
42
+ ```
43
+
44
+ ## Reference documentation
45
+
46
+ - dora-microphone
47
+ - github: https://github.com/dora-rs/dora/blob/main/node-hub/dora-microphone
48
+ - website: http://dora-rs.ai/docs/nodes/microphone
49
+ - sounddevice
50
+ - website: https://python-sounddevice.readthedocs.io/en/0.5.1/
51
+ - github: https://github.com/spatialaudio/python-sounddevice/tree/master
52
+
53
+ ## Examples
54
+
55
+ - Speech to Text
56
+ - github: https://github.com/dora-rs/dora/blob/main/examples/speech-to-text
57
+ - website: https://dora-rs.ai/docs/examples/stt
58
+
59
+ ## License
60
+
61
+ The code and model weights are released under the MIT License.
@@ -0,0 +1,7 @@
1
+ dora_microphone/__init__.py,sha256=HuSK3dnyI9Pb5QAuaKFwQQ3J5SIZnLcKHPJO0norGzc,353
2
+ dora_microphone/main.py,sha256=HFVMjg2Rnf-1HvzlgLSx_xfCPlyyujCvo8maIw9NMGk,1171
3
+ dora_microphone-0.3.9.dist-info/METADATA,sha256=mHxkBo-JU4mDz2i68yaCg1vzSlJfSwwbYATqsBrFJKU,1738
4
+ dora_microphone-0.3.9.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
+ dora_microphone-0.3.9.dist-info/entry_points.txt,sha256=DNnYiww0gxWJRDlgg-aQ3sj5Oo61siIvyAvjd0YMYeE,62
6
+ dora_microphone-0.3.9.dist-info/top_level.txt,sha256=AEkdHx6GH6vSz7Sc-KBOY9GbElitzMn5mORnK7GA7P8,16
7
+ dora_microphone-0.3.9.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ dora-microphone = dora_microphone.main:main
@@ -0,0 +1 @@
1
+ dora_microphone
@@ -1,31 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: dora-microphone
3
- Version: 0.3.7rc2
4
- Summary: Dora dora-microphone
5
- Home-page: https://github.com/dora-rs/dora.git
6
- License: MIT
7
- Author: Haixuan Xavier Tao
8
- Author-email: tao.xavier@outlook.com
9
- Requires-Python: >=3.7,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.7
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Requires-Dist: dora-rs (>=0.3.6,<0.4.0)
20
- Requires-Dist: numpy (<2.0.0)
21
- Requires-Dist: pyarrow (>=5.0.0)
22
- Requires-Dist: sounddevice (>=0.4.6,<0.5.0)
23
- Project-URL: Documentation, https://github.com/dora-rs/dora/blob/main/node-hub/dora-microphone/README.md
24
- Description-Content-Type: text/markdown
25
-
26
- # Dora Node for recording data from microphone
27
-
28
- This node will send data as soon as the microphone volume is higher than a threshold.
29
-
30
- Check example at [examples/speech-to-text](examples/speech-to-text)
31
-
@@ -1,6 +0,0 @@
1
- dora_microphone/__init__.py,sha256=Gy4qL4vCeTyA5HR1Yp3ioL4-ClJyW8oi_38CzMuMsBM,358
2
- dora_microphone/main.py,sha256=V_ig3WoKbdTDLJ4rGvGMSAb_AjGZw-Z-2DY9Je-Z9XI,1006
3
- dora_microphone-0.3.7rc2.dist-info/METADATA,sha256=cc1CR7PQrFjsgMOTXXPdsqHlESVuK5r893aROOFMVLI,1194
4
- dora_microphone-0.3.7rc2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
5
- dora_microphone-0.3.7rc2.dist-info/entry_points.txt,sha256=T7lmS26gTsxKwY0UAyR6GkjNDGYbyAFVzl94yMSePKc,61
6
- dora_microphone-0.3.7rc2.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- dora-microphone=dora_microphone.main:main
3
-