Repository navigation
Expand file tree
/
Copy pathsample.py
More file actions
70 lines (55 loc) · 2.5 KB
/
Copy pathsample.py
File metadata and controls
70 lines (55 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
:filename: sample.py
:author: Brigitte Bigi
:contact: contact@sppas.org
:summary: A script to demonstrate AudiooPy capabilities.
.. _This file is part of AudiooPy:
..
---------------------------------------------------------------------
Copyright (C) 2024-205 Brigitte Bigi, CNRS
Laboratoire Parole et Langage, Aix-en-Provence, France
Use of this software is governed by the GNU Public License, version 3.
AudiooPy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
AudiooPy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AudiooPy. If not, see <https://www.gnu.org/licenses/>.
This banner notice must not be removed.
---------------------------------------------------------------------
"""
import logging
import audioopy.aio
from audioopy.ipus.channelsilences import ChannelSilences
from audioopy.ipus.searchfor import SearchForIPUs
logging.getLogger().setLevel(0)
# Extract the only channel of the oriana1.wav sample
audio = audioopy.aio.open("tests/samples/oriana1.wav")
audio.extract_channel(0)
channel = audio[0]
# Create ChannelSilences() instance: estimate the rms values in windows of 20 ms length
channel_silences = ChannelSilences(channel, win_len=0.02, vagueness=0.005)
# Search for all the silences, comparing each rms to an automatically estimated threshold
threshold = channel_silences.search_silences()
print(list(channel_silences))
# Keep only silences during more than a given duration
channel_silences.filter_silences(threshold // 2, 0.250)
print(list(channel_silences))
# Get the (from_pos, to_pos) of the tracks during more than a given duration
tracks_1 = channel_silences.extract_tracks(0.300, 0.02, 0.02)
print(tracks_1)
# Create a SearchForIPUs() instance
searcher = SearchForIPUs(channel)
# Perform the full process and return tracks in the frames domain
tracks_2 = searcher.get_tracks(time_domain=False)
print(tracks_2)
assert tracks_1 == tracks_2
# Perform the full process and return tracks in the time domain
tracks = searcher.get_tracks(time_domain=True)
print(tracks)