amine@344
|
1 .. image:: doc/figures/auditok-logo.png
|
amsehili@343
|
2 :align: center
|
amsehili@343
|
3
|
amine@336
|
4 .. image:: https://travis-ci.org/amsehili/auditok.svg?branch=master
|
amine@336
|
5 :target: https://travis-ci.org/amsehili/auditok
|
amine@336
|
6
|
amine@336
|
7 .. image:: https://readthedocs.org/projects/auditok/badge/?version=latest
|
amine@336
|
8 :target: http://auditok.readthedocs.org/en/latest/?badge=latest
|
amine@336
|
9 :alt: Documentation Status
|
amine@336
|
10
|
amine@374
|
11 ``auditok`` is an **Audio Activity Detection** tool that can process online data
|
amine@374
|
12 (read from an audio device or from standard input) as well as audio files.
|
amine@374
|
13 It can be used as a command line program or by calling its API.
|
amsehili@349
|
14
|
amine@374
|
15 The latest version of the documentation can be found on
|
amine@374
|
16 `readthedocs. <https://readthedocs.org/projects/auditok/badge/?version=latest>`_
|
amsehili@349
|
17
|
amsehili@349
|
18
|
amsehili@349
|
19 Installation
|
amsehili@349
|
20 ------------
|
amsehili@349
|
21
|
amine@374
|
22 A basic version of ``auditok`` will run with standard Python (>=3.4). However,
|
amine@374
|
23 without installing additional dependencies, ``auditok`` can only deal with audio
|
amine@374
|
24 files in *wav* or *raw* formats. if you want more features, the following
|
amine@374
|
25 packages are needed:
|
amine@374
|
26
|
amine@375
|
27 - `pydub <https://github.com/jiaaro/pydub>`_ : read audio files in popular audio formats (ogg, mp3, etc.) or extract audio from a video file.
|
amine@375
|
28 - `pyaudio <http://people.csail.mit.edu/hubert/pyaudio/>`_ : read audio data from the microphone and play audio back.
|
amine@375
|
29 - `tqdm <https://github.com/tqdm/tqdm>`_ : show progress bar while playing audio clips.
|
amine@375
|
30 - `matplotlib <https://matplotlib.org/stable/index.html>`_ : plot audio signal and detections.
|
amine@375
|
31 - `numpy <https://numpy.org/>`_ : required by matplotlib. Also used for some math operations instead of standard python if available.
|
amine@375
|
32
|
amine@375
|
33 Install the latest stable version with pip:
|
amine@375
|
34
|
amine@375
|
35 .. code:: bash
|
amine@375
|
36
|
amine@375
|
37 sudo pip install auditok
|
amine@375
|
38
|
amine@375
|
39 Install with the latest version from github:
|
amine@374
|
40
|
amsehili@349
|
41 .. code:: bash
|
amsehili@349
|
42
|
amsehili@354
|
43 pip install git+https://github.com/amsehili/auditok
|
amsehili@354
|
44
|
amine@375
|
45 or
|
amine@375
|
46
|
amine@375
|
47 .. code:: bash
|
amine@375
|
48
|
amine@375
|
49 git clone https://github.com/amsehili/auditok.git
|
amine@375
|
50 cd auditok
|
amine@375
|
51 python setup.py install
|
amine@375
|
52
|
amsehili@349
|
53
|
amsehili@343
|
54 Basic example
|
amsehili@343
|
55 -------------
|
amsehili@343
|
56
|
amine@336
|
57 .. code:: python
|
amine@336
|
58
|
amine@374
|
59 import auditok
|
amsehili@343
|
60
|
amsehili@343
|
61 # split returns a generator of AudioRegion objects
|
amine@374
|
62 audio_regions = auditok.split(
|
amine@374
|
63 "audio.wav",
|
amine@374
|
64 min_dur=0.2, # minimum duration of a valid audio event in seconds
|
amine@374
|
65 max_dur=4, # maximum duration of an event
|
amine@374
|
66 max_silence=0.3, # maximum duration of tolerated continuous silence within an event
|
amine@374
|
67 energy_threshold=55 # threshold of detection
|
amine@374
|
68 )
|
amine@375
|
69
|
amine@375
|
70 for i, r in enumerate(audio_regions):
|
amine@375
|
71
|
amine@376
|
72 # Regions returned by `split` have 'start' and 'end' metadata fields
|
amine@375
|
73 print("Region {i}: {r.meta.start:.3f}s -- {r.meta.end:.3f}s".format(i=i, r=r))
|
amine@375
|
74
|
amine@375
|
75 # play detection
|
amine@375
|
76 # r.play(progress_bar=True)
|
amine@375
|
77
|
amine@376
|
78 # region's metadata can also be used with the `save` method
|
amine@375
|
79 # (no need to explicitly specify region's object and `format` arguments)
|
amine@375
|
80 filename = r.save("region_{meta.start:.3f}-{meta.end:.3f}.wav")
|
amine@336
|
81 print("region saved as: {}".format(filename))
|
amine@336
|
82
|
amine@375
|
83 output example:
|
amine@375
|
84
|
amine@375
|
85 .. code:: bash
|
amine@375
|
86
|
amine@375
|
87 Region 0: 0.700s -- 1.400s
|
amine@375
|
88 region saved as: region_0.700-1.400.wav
|
amine@375
|
89 Region 1: 3.800s -- 4.500s
|
amine@375
|
90 region saved as: region_3.800-4.500.wav
|
amine@375
|
91 Region 2: 8.750s -- 9.950s
|
amine@375
|
92 region saved as: region_8.750-9.950.wav
|
amine@375
|
93 Region 3: 11.700s -- 12.400s
|
amine@375
|
94 region saved as: region_11.700-12.400.wav
|
amine@375
|
95 Region 4: 15.050s -- 15.850s
|
amine@375
|
96 region saved as: region_15.050-15.850.wav
|
amine@375
|
97
|
amine@375
|
98
|
amine@374
|
99 Split and plot
|
amine@374
|
100 --------------
|
amine@336
|
101
|
amine@375
|
102 Visualize audio signal and detections:
|
amine@375
|
103
|
amine@336
|
104 .. code:: python
|
amine@336
|
105
|
amine@374
|
106 import auditok
|
amine@374
|
107 region = auditok.load("audio.wav") # returns an AudioRegion object
|
amine@375
|
108 regions = region.split_and_plot(...) # or just region.splitp()
|
amine@336
|
109
|
amsehili@349
|
110 output figure:
|
amine@336
|
111
|
amine@336
|
112 .. image:: doc/figures/example_1.png
|
amsehili@349
|
113
|
amine@375
|
114
|
amine@374
|
115 Limitations
|
amine@374
|
116 -----------
|
amsehili@349
|
117
|
amine@374
|
118 Currently, the core detection algorithm is based on the energy of audio signal.
|
amine@374
|
119 While this is fast and works very well for audio streams with low background
|
amine@374
|
120 noise (e.g., podcasts with few people talking, language lessons, audio recorded
|
amine@374
|
121 in a rather quiet environment, etc.) the performance can drop as the level of
|
amine@374
|
122 noise increases. Furthermore, the algorithm makes now distinction between speech
|
amine@374
|
123 and other kinds of sounds, so you shouldn't use it for Voice Activity Detection
|
amine@376
|
124 if your audio data also contain non-speech events.
|
amsehili@349
|
125
|
amsehili@349
|
126 License
|
amsehili@349
|
127 -------
|
amsehili@349
|
128 MIT.
|