Spaces:
Running
Running
Commit
·
1b97239
1
Parent(s):
49997c9
Initial
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .data/example/LogisticsCallCenterConversation.mp3 +3 -0
- .data/example/noisy/LookOncetoHearTargetSpeechHearingwithNoisyExamples.mp3 +3 -0
- .data/groundtruth/speakerverification/DatasetCard.md +221 -0
- .data/groundtruth/speakerverification/LICENSE +674 -0
- .data/groundtruth/speakerverification/call/v1/Call01.srt +41 -0
- .data/groundtruth/speakerverification/call/v1/Call01.wav +3 -0
- .data/groundtruth/speakerverification/call/v1/Call02.srt +43 -0
- .data/groundtruth/speakerverification/call/v1/Call02.wav +3 -0
- .data/groundtruth/speakerverification/call/v1/metadata.json +14 -0
- .data/groundtruth/speakerverification/voiceprint/v1/CSR01.wav +3 -0
- .data/groundtruth/speakerverification/voiceprint/v1/metadata.json +20 -0
- .db/Callytics.sqlite +0 -0
- .docs/documentation/CONTRIBUTING.md +606 -0
- .docs/documentation/RESOURCES.md +119 -0
- .docs/img/Callytics.drawio +164 -0
- .docs/img/Callytics.gif +3 -0
- .docs/img/Callytics.png +3 -0
- .docs/img/Callytics.svg +4 -0
- .docs/img/CallyticsIcon.png +3 -0
- .docs/img/callyticsDemo.gif +3 -0
- .docs/img/database.png +3 -0
- .docs/presentation/CallyticsPresentationEN.pdf +3 -0
- .gitattributes +6 -0
- .github/CODEOWNERS +1 -0
- .gitignore +8 -0
- LICENSE +674 -0
- README.md +543 -11
- automation/service/callytics.service +19 -0
- config/config.yaml +26 -0
- config/nemo/diar_infer_telephonic.yaml +86 -0
- config/prompt.yaml +107 -0
- environment.yaml +31 -0
- main.py +292 -0
- requirements.txt +23 -0
- src/__init__.py +5 -0
- src/audio/__init__.py +0 -0
- src/audio/alignment.py +137 -0
- src/audio/analysis.py +715 -0
- src/audio/effect.py +114 -0
- src/audio/error.py +214 -0
- src/audio/io.py +248 -0
- src/audio/metrics.py +242 -0
- src/audio/preprocessing.py +267 -0
- src/audio/processing.py +614 -0
- src/audio/utils.py +189 -0
- src/db/__init__.py +0 -0
- src/db/manager.py +149 -0
- src/db/sql/AudioPropertiesInsert.sql +34 -0
- src/db/sql/Schema.sql +62 -0
- src/db/sql/TopicFetch.sql +2 -0
.data/example/LogisticsCallCenterConversation.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b8d26ffeb161abdf165a1f4700b627962e5b64ddb921daaa79d6373437824f84
|
3 |
+
size 551372
|
.data/example/noisy/LookOncetoHearTargetSpeechHearingwithNoisyExamples.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7cc7bc2d31959e65d6856860038cb57cd5d8cba39380e24a25597afdf29ce813
|
3 |
+
size 677902
|
.data/groundtruth/speakerverification/DatasetCard.md
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Callytics Speaker Verification Dataset *(CSVD)*
|
2 |
+
|
3 |
+
This dataset, named **Callytics Speaker Verification Dataset** (CSVD), was created to test and develop **Speaker
|
4 |
+
Verification**
|
5 |
+
models specifically for the `Callytics` project. It primarily features Turkish speakers and was developed in
|
6 |
+
collaboration with Turkish student volunteers. The recordings originate from WhatsApp phone calls, which were captured
|
7 |
+
using the Cube ASR mobile application in AMR format and later converted to WAV using FFmpeg.
|
8 |
+
|
9 |
+
---
|
10 |
+
|
11 |
+
### Table of Contents
|
12 |
+
|
13 |
+
- [Features](#features)
|
14 |
+
- [File Structure](#file-structure)
|
15 |
+
- [Metadata](#metadata)
|
16 |
+
- [Transcript](#transcript)
|
17 |
+
- [Versioning](#versioning)
|
18 |
+
- [Upcoming](#Upcoming)
|
19 |
+
- [License](#licence)
|
20 |
+
- [Team](#team)
|
21 |
+
- [Contact](#contact)
|
22 |
+
- [Citation](#citation)
|
23 |
+
|
24 |
+
---
|
25 |
+
|
26 |
+
### Features
|
27 |
+
|
28 |
+
- **Dataset Name**: **Callytics Speaker Verification Dataset _(CSVD)_**
|
29 |
+
- **Version**: v1 (Initial)
|
30 |
+
- **Purpose**: This dataset is created to test and develop **Speaker Verification** models, especially for the
|
31 |
+
`Callytics` project.
|
32 |
+
- **Language / Accent**: Primarily Turkish speakers
|
33 |
+
- **Contributors**: Created in collaboration with Turkish student volunteers.
|
34 |
+
- **Recording Source**: WhatsApp calls (originally AMR) captured Cube ASR mobile application and then converted to WAV
|
35 |
+
using FFmpeg.
|
36 |
+
|
37 |
+
This version (v1) contains **10 samples** of phone calls involving **Customer Service Representative (CSR)** and *
|
38 |
+
*Customer* roles. The audio files are stored in **WAV** format with the following specifications:
|
39 |
+
|
40 |
+
- **Channels**: Mono
|
41 |
+
- **Format**: WAV
|
42 |
+
- **Audio Bitrate**: 128 kbps
|
43 |
+
- **Sample Rate**: 8.00 kHz
|
44 |
+
- **Conversion**: AMR → WAV
|
45 |
+
|
46 |
+
---
|
47 |
+
|
48 |
+
### File Structure
|
49 |
+
|
50 |
+
```Text
|
51 |
+
.
|
52 |
+
└── speakerverification
|
53 |
+
├── call
|
54 |
+
│ └── v1
|
55 |
+
│ ├── Call01.wav
|
56 |
+
│ ├── Call02.wav
|
57 |
+
│ └── metadata.json
|
58 |
+
├── DatasetCard.md
|
59 |
+
├── LICENSE
|
60 |
+
├── README.md
|
61 |
+
└── voiceprint
|
62 |
+
└── v1
|
63 |
+
├── CSR01.wav
|
64 |
+
└── metadata.json
|
65 |
+
|
66 |
+
6 directories, 7 files
|
67 |
+
```
|
68 |
+
|
69 |
+
- **call**: Contains call samples (Call01.wav, Call02.wav, etc.) plus a metadata.json.
|
70 |
+
- **voiceprint/v1**: Contains shorter CSR recordings (CSR01.wav, etc.) plus a metadata.json.
|
71 |
+
- **DatasetCard.md**: This document, explaining dataset details.
|
72 |
+
- **LICENSE**: License file for the dataset.
|
73 |
+
|
74 |
+
---
|
75 |
+
|
76 |
+
### Metadata
|
77 |
+
|
78 |
+
##### Call Metadata
|
79 |
+
|
80 |
+
###### Sample
|
81 |
+
|
82 |
+
```json
|
83 |
+
{
|
84 |
+
"file_id": "Call01.wav",
|
85 |
+
"csr_id": "CSR01",
|
86 |
+
"duration": 1.13,
|
87 |
+
"recorded": "2025-02-11"
|
88 |
+
}
|
89 |
+
```
|
90 |
+
|
91 |
+
- **file_id**: Filename of the audio file.
|
92 |
+
- **csr_id**: CSR identifier.
|
93 |
+
- **duration**: Duration of the call.
|
94 |
+
- **recorded**: Recording date.
|
95 |
+
|
96 |
+
##### Voiceprint Metadata
|
97 |
+
|
98 |
+
###### Sample
|
99 |
+
|
100 |
+
```json
|
101 |
+
{
|
102 |
+
"file_id": "CSR01.wav",
|
103 |
+
"csr_id": "CSR01",
|
104 |
+
"gender": "F",
|
105 |
+
"age": 22,
|
106 |
+
"duration": 0.7,
|
107 |
+
"transcript": "Hello and welcome to Callytics! My name is Emily. How may I assist you?",
|
108 |
+
"recorded": "2025-02-11"
|
109 |
+
}
|
110 |
+
```
|
111 |
+
|
112 |
+
- **file_id**: Filename of the audio file.
|
113 |
+
- **csr_id**: CSR identifier.
|
114 |
+
- **gender**: Gender of CSR.
|
115 |
+
- **age**: Age of CSR.
|
116 |
+
- **duration**: Duration of the Voice Print.
|
117 |
+
- **recorded**: Recording date.
|
118 |
+
|
119 |
+
---
|
120 |
+
|
121 |
+
### Transcript
|
122 |
+
|
123 |
+
We provide SRT transcripts for each call under the `call/v1` directory. Each `.srt` file contains:
|
124 |
+
|
125 |
+
- Speaker labels
|
126 |
+
- Time stamps in `HH:MM:SS,MMM` format
|
127 |
+
- Conversation text
|
128 |
+
|
129 |
+
Such as:
|
130 |
+
|
131 |
+
- `Call01.wav` has a corresponding `Call01.srt`
|
132 |
+
- `Call02.wav` has a corresponding `Call02.srt`
|
133 |
+
|
134 |
+
###### Annotation Process
|
135 |
+
|
136 |
+
The timestamps in the transcripts were manually annotated using **Audacity** for precise time labeling.
|
137 |
+
|
138 |
+
###### Transcript Sample
|
139 |
+
|
140 |
+
```Text
|
141 |
+
1
|
142 |
+
00:00:03,453 --> 00:00:09,166
|
143 |
+
[CSR] Hello and welcome to Callytics! My name is Emily. How may I assist you?
|
144 |
+
|
145 |
+
2
|
146 |
+
00:00:09,582 --> 00:00:20,410
|
147 |
+
[Customer] Hi, Emily. I’ve been having trouble receiving notification emails.
|
148 |
+
They used to arrive instantly, but now there’s a long delay.
|
149 |
+
|
150 |
+
3
|
151 |
+
00:00:20,599 --> 00:00:27,879
|
152 |
+
[CSR] I’m sorry for the inconvenience. Let me take a look.
|
153 |
+
Could you give me your account details so I can verify the email settings?
|
154 |
+
```
|
155 |
+
|
156 |
+
---
|
157 |
+
|
158 |
+
### Versioning
|
159 |
+
|
160 |
+
- `v1 (Initial)`
|
161 |
+
|
162 |
+
---
|
163 |
+
|
164 |
+
### Upcoming
|
165 |
+
|
166 |
+
- [ ] **Potentially larger sets of calls**
|
167 |
+
- [ ] **Inclusion of new languages or dialects**
|
168 |
+
- [ ] **Measure Audio Data Quality**
|
169 |
+
- *General Data Quality Indicators*
|
170 |
+
- [ ] Completeness
|
171 |
+
- [ ] Accuracy
|
172 |
+
- [ ] Consistency
|
173 |
+
- [ ] Uniqueness (Duplicate Check)
|
174 |
+
- [ ] Coverage / Diversity
|
175 |
+
- [ ] Timeliness
|
176 |
+
- [ ] Class Balance and Metadata Richness
|
177 |
+
- *Audio-Specific Quality Indicators*
|
178 |
+
- [ ] Signal-to-Noise Ratio (SNR)
|
179 |
+
- [ ] Distortion Measures
|
180 |
+
- [ ] Clipping Rate (Clipped Samples)
|
181 |
+
- [ ] Silence Ratio
|
182 |
+
- [ ] Noise Types and Levels
|
183 |
+
- [ ] Reverberation (Echo) Ratio / DRR (Direct to Reverberant Ratio)
|
184 |
+
- [ ] Speaker / Content Distribution
|
185 |
+
- [ ] Transcription Quality
|
186 |
+
|
187 |
+
---
|
188 |
+
|
189 |
+
### Licence
|
190 |
+
|
191 |
+
- [LICENSE](LICENSE)
|
192 |
+
|
193 |
+
---
|
194 |
+
|
195 |
+
### Team
|
196 |
+
|
197 |
+
- [Bunyamin Ergen](https://www.linkedin.com/in/bunyaminergen)
|
198 |
+
- **Turkish Volunteers**
|
199 |
+
|
200 |
+
---
|
201 |
+
|
202 |
+
### Contact
|
203 |
+
|
204 |
+
- [Mail](mailto:[email protected])
|
205 |
+
|
206 |
+
---
|
207 |
+
|
208 |
+
### Citation
|
209 |
+
|
210 |
+
```bibtex
|
211 |
+
@software{ CSVD,
|
212 |
+
author = {Bunyamin Ergen},
|
213 |
+
title = {Callytics Speaker Verification Dataset},
|
214 |
+
year = {2025},
|
215 |
+
month = {02},
|
216 |
+
url = {https://github.com/bunyaminergen/Callytics},
|
217 |
+
version = {v1},
|
218 |
+
}
|
219 |
+
```
|
220 |
+
|
221 |
+
---
|
.data/groundtruth/speakerverification/LICENSE
ADDED
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<https://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
.data/groundtruth/speakerverification/call/v1/Call01.srt
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1
|
2 |
+
00:00:03,453 --> 00:00:09,166
|
3 |
+
[CSR] Hello and welcome to Callytics! My name is Emily. How may I assist you?
|
4 |
+
|
5 |
+
2
|
6 |
+
00:00:09,582 --> 00:00:20,410
|
7 |
+
[Customer] Hi, Emily. I’ve been having trouble receiving notification emails.
|
8 |
+
They used to arrive instantly, but now there’s a long delay.
|
9 |
+
|
10 |
+
3
|
11 |
+
00:00:20,599 --> 00:00:27,879
|
12 |
+
[CSR] I’m sorry for the inconvenience. Let me take a look.
|
13 |
+
Could you give me your account details so I can verify the email settings?
|
14 |
+
|
15 |
+
4
|
16 |
+
00:00:28,552 --> 00:00:35,850
|
17 |
+
[Customer] Of course. My username is user101,
|
18 |
+
and the associated email is [email protected].
|
19 |
+
|
20 |
+
5
|
21 |
+
00:00:38,028 --> 00:00:51,882
|
22 |
+
[CSR] Thank you. Checking now… It appears your notification preferences
|
23 |
+
were reset during a recent update. I’ll adjust them back to real-time alerts,
|
24 |
+
so you should start getting prompt emails again.
|
25 |
+
|
26 |
+
6
|
27 |
+
00:00:52,630 --> 00:00:56,053
|
28 |
+
[Customer] That’s great news. Thanks for fixing it so quickly!
|
29 |
+
|
30 |
+
7
|
31 |
+
00:00:57,656 --> 00:01:05,947
|
32 |
+
[CSR] You’re welcome. Thanks for contacting Callytics.
|
33 |
+
Let me know if there’s anything else I can do for you today.
|
34 |
+
|
35 |
+
8
|
36 |
+
00:01:06,016 --> 00:01:08,364
|
37 |
+
[Customer] Nope, that’s everything. Have a good day, Emily.
|
38 |
+
|
39 |
+
9
|
40 |
+
00:01:09,016 --> 00:01:11,575
|
41 |
+
[CSR] You too! Take care. Goodbye.
|
.data/groundtruth/speakerverification/call/v1/Call01.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ea0565b308937e3cee7c22b5e66d57e728b5fdeb68a1a57998d75dbb15f8ac2d
|
3 |
+
size 1176078
|
.data/groundtruth/speakerverification/call/v1/Call02.srt
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1
|
2 |
+
00:00:03,599 --> 00:00:09,557
|
3 |
+
[CSR] Hi there! You’ve reached Callytics Support, and this is Emily speaking. What can I do for you today?
|
4 |
+
|
5 |
+
2
|
6 |
+
00:00:10,153 --> 00:00:17,480
|
7 |
+
[Customer] Hello, Emily. I recently upgraded to your premium subscription, but I haven’t seen
|
8 |
+
any new features activated on my account.
|
9 |
+
|
10 |
+
3
|
11 |
+
00:00:19,213 --> 00:00:26,634
|
12 |
+
[CSR] Thanks for letting me know. Could you share your account email or username so I
|
13 |
+
can check what might be causing the issue?
|
14 |
+
|
15 |
+
4
|
16 |
+
00:00:26,825 --> 00:00:30,914
|
17 |
+
[Customer] Sure, my email is [email protected].
|
18 |
+
|
19 |
+
5
|
20 |
+
00:00:32,677 --> 00:00:49,882
|
21 |
+
[CSR] Perfect. One moment while I look that up… It appears there was a slight delay with
|
22 |
+
the activation. I’ll go ahead and expedite the process. Your premium features should be live within
|
23 |
+
the next 15 minutes.
|
24 |
+
|
25 |
+
6
|
26 |
+
00:00:49,933 --> 00:00:51,769
|
27 |
+
[Customer] Great, thank you so much for resolving that!
|
28 |
+
|
29 |
+
7
|
30 |
+
00:00:53,567 --> 00:00:56,095
|
31 |
+
[CSR] You’re welcome. Is there anything else I can help you with?
|
32 |
+
|
33 |
+
8
|
34 |
+
00:00:56,647 --> 00:00:57,772
|
35 |
+
[Customer] That’s all. Thanks again!
|
36 |
+
|
37 |
+
9
|
38 |
+
00:00:59,079 --> 00:01:03,559
|
39 |
+
[CSR] My pleasure. Thanks for reaching out to Callytics, and have a wonderful day!
|
40 |
+
|
41 |
+
10
|
42 |
+
00:01:04,203 --> 00:01:04,942
|
43 |
+
[Customer] Thank you.
|
.data/groundtruth/speakerverification/call/v1/Call02.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:16bf930546b29eccdb12a5441f7f66a3a9a83246d2dbef03f4fcac2d319db862
|
3 |
+
size 1072078
|
.data/groundtruth/speakerverification/call/v1/metadata.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"file_id": "Call01.wav",
|
4 |
+
"csr_id": "CSR01",
|
5 |
+
"duration": 1.13,
|
6 |
+
"recorded": "2025-02-11"
|
7 |
+
},
|
8 |
+
{
|
9 |
+
"file_id": "Call02.wav",
|
10 |
+
"csr_id": "CSR01",
|
11 |
+
"duration": 1.7,
|
12 |
+
"recorded": "2025-02-11"
|
13 |
+
}
|
14 |
+
]
|
.data/groundtruth/speakerverification/voiceprint/v1/CSR01.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ac3ea280d838d08d977c6b8ce061a09d169b70399cb170476df29dbe1ec49bb8
|
3 |
+
size 189198
|
.data/groundtruth/speakerverification/voiceprint/v1/metadata.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"file_id": "CSR01.wav",
|
4 |
+
"csr_id": "CSR01",
|
5 |
+
"gender": "F",
|
6 |
+
"age": 22,
|
7 |
+
"duration": 0.7,
|
8 |
+
"transcript": "Hello and welcome to Callytics! My name is Emily. How may I assist you?",
|
9 |
+
"recorded": "2025-02-11"
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"file_id": "CSR02.wav",
|
13 |
+
"csr_id": "CSR02",
|
14 |
+
"gender": "F",
|
15 |
+
"age": 22,
|
16 |
+
"duration": 0.12,
|
17 |
+
"transcript": "Hello and welcome to Callytics! My name is Emily. How may I assist you?",
|
18 |
+
"recorded": "2025-02-11"
|
19 |
+
}
|
20 |
+
]
|
.db/Callytics.sqlite
ADDED
Binary file (53.2 kB). View file
|
|
.docs/documentation/CONTRIBUTING.md
ADDED
@@ -0,0 +1,606 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributing to [Project]
|
2 |
+
|
3 |
+
Thank you for your interest in contributing to this project! We’re excited to have you on board. This guide is designed
|
4 |
+
to make the contribution process clear and efficient.
|
5 |
+
|
6 |
+
---
|
7 |
+
|
8 |
+
## Table of Contents
|
9 |
+
|
10 |
+
1. [How to Contribute?](#how-to-contribute)
|
11 |
+
- [Reporting Issues](#reporting-issues)
|
12 |
+
- [Suggesting Features](#suggesting-features)
|
13 |
+
- [Coding Standards](#coding-standards)
|
14 |
+
- [File Structure](#file-structure)
|
15 |
+
- [Commit Message Guidelines](#commit-message-guidelines)
|
16 |
+
- [Branches](#branches)
|
17 |
+
- [File Naming Convention](#file-naming-convention)
|
18 |
+
- [Versioning, Release, Tag](#versioning-release-tag)
|
19 |
+
|
20 |
+
---
|
21 |
+
|
22 |
+
## How to Contribute?
|
23 |
+
|
24 |
+
### Reporting Issues
|
25 |
+
|
26 |
+
- If you find a bug, please open a new issue on the [GitHub Issues](https://github.com/[username]/[project-name]/issues)
|
27 |
+
page.
|
28 |
+
- Include the following details:
|
29 |
+
- A clear and descriptive title.
|
30 |
+
- Steps to reproduce the issue.
|
31 |
+
- Expected vs. actual behavior.
|
32 |
+
- Screenshots or error logs if applicable.
|
33 |
+
|
34 |
+
### Suggesting Features
|
35 |
+
|
36 |
+
- Have a great idea for a new feature? Open a new **Issue** and describe your suggestion.
|
37 |
+
- Explain how this feature will improve the project.
|
38 |
+
|
39 |
+
### Coding Standards
|
40 |
+
|
41 |
+
##### Import Order
|
42 |
+
|
43 |
+
Follow the import order below to maintain consistency in the codebase:
|
44 |
+
|
45 |
+
1. **Standard library imports**
|
46 |
+
2. **Third-party imports**
|
47 |
+
3. **Local application/library specific imports**
|
48 |
+
|
49 |
+
**Example:**
|
50 |
+
|
51 |
+
```python
|
52 |
+
# Standard library imports
|
53 |
+
import os
|
54 |
+
import sys
|
55 |
+
|
56 |
+
# Third-party imports
|
57 |
+
import numpy as np
|
58 |
+
import pandas as pd
|
59 |
+
|
60 |
+
# Local imports
|
61 |
+
from my_module import my_function
|
62 |
+
```
|
63 |
+
|
64 |
+
> **INFO**
|
65 |
+
>
|
66 |
+
> *For more detail, please check*:
|
67 |
+
> - [PEP 8 – Style Guide for Python Code | peps.python.org](https://peps.python.org/pep-0008/)
|
68 |
+
|
69 |
+
##### Docstring
|
70 |
+
|
71 |
+
Use `NumPy` format for docstrings in both functions and classes:
|
72 |
+
|
73 |
+
- Each function or class should have a docstring explaining its purpose, parameters, return values, and examples if
|
74 |
+
applicable.
|
75 |
+
- For classes, include a class-level docstring that describes the overall purpose of the class, any parameters for
|
76 |
+
`__init__`, and details on attributes and methods.
|
77 |
+
- If you include references (e.g., research papers, algorithms, or external resources) in your docstring, create a
|
78 |
+
separate `References` section clearly listing these sources at the end of your docstring.
|
79 |
+
|
80 |
+
Example for a function:
|
81 |
+
|
82 |
+
```python
|
83 |
+
# Standard library imports
|
84 |
+
from typing import Annotated
|
85 |
+
|
86 |
+
|
87 |
+
def example_function(
|
88 |
+
param1: Annotated[int, "Description of param1"],
|
89 |
+
param2: Annotated[str, "Description of param2"]
|
90 |
+
) -> Annotated[bool, "Description of the return value"]:
|
91 |
+
"""
|
92 |
+
Brief description of what the function does.
|
93 |
+
|
94 |
+
Parameters
|
95 |
+
----------
|
96 |
+
param1 : int
|
97 |
+
Description of param1.
|
98 |
+
param2 : str
|
99 |
+
Description of param2.
|
100 |
+
|
101 |
+
Returns
|
102 |
+
-------
|
103 |
+
bool
|
104 |
+
Description of the return value.
|
105 |
+
|
106 |
+
Examples
|
107 |
+
--------
|
108 |
+
>>> example_function(5, 'hello')
|
109 |
+
True
|
110 |
+
>>> example_function(0, '')
|
111 |
+
False
|
112 |
+
|
113 |
+
References
|
114 |
+
----------
|
115 |
+
* Doe, John. "A Study on Example Functions." Journal of Examples, 2021.
|
116 |
+
"""
|
117 |
+
return bool(param1) and bool(param2)
|
118 |
+
```
|
119 |
+
|
120 |
+
Example for a class:
|
121 |
+
|
122 |
+
```python
|
123 |
+
class MyClass:
|
124 |
+
"""
|
125 |
+
MyClass demonstrates the use of docstrings with a separate References section.
|
126 |
+
|
127 |
+
This class provides an example of structuring docstrings, including attributes,
|
128 |
+
methods, usage examples, and a references section when external sources are cited.
|
129 |
+
|
130 |
+
Parameters
|
131 |
+
----------
|
132 |
+
param1 : str
|
133 |
+
Description of `param1`, explaining its purpose and specific constraints.
|
134 |
+
param2 : int, optional
|
135 |
+
Description of `param2`. Defaults to 0.
|
136 |
+
|
137 |
+
Attributes
|
138 |
+
----------
|
139 |
+
attribute1 : str
|
140 |
+
Description of `attribute1`, explaining its purpose and possible values.
|
141 |
+
attribute2 : int
|
142 |
+
Description of `attribute2`, outlining constraints or expected values.
|
143 |
+
|
144 |
+
Methods
|
145 |
+
-------
|
146 |
+
example_method(param1, param2=None)
|
147 |
+
Example method description.
|
148 |
+
|
149 |
+
Examples
|
150 |
+
--------
|
151 |
+
Create an instance and use methods:
|
152 |
+
|
153 |
+
>>> my_instance = MyClass("example", 5)
|
154 |
+
>>> my_instance.example_method("sample")
|
155 |
+
|
156 |
+
References
|
157 |
+
----------
|
158 |
+
* Smith, Jane. "Guide to Effective Python Documentation." Python Publishing, 2020.
|
159 |
+
* Hu, Jie, Li Shen, and Gang Sun. "Squeeze-and-Excitation Networks."
|
160 |
+
IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018.
|
161 |
+
"""
|
162 |
+
|
163 |
+
def __init__(self, param1, param2=0):
|
164 |
+
"""
|
165 |
+
Initializes the class.
|
166 |
+
|
167 |
+
Parameters
|
168 |
+
----------
|
169 |
+
param1 : str
|
170 |
+
Explanation of `param1`.
|
171 |
+
param2 : int, optional
|
172 |
+
Explanation of `param2`. Defaults to 0.
|
173 |
+
"""
|
174 |
+
self.attribute1 = param1
|
175 |
+
self.attribute2 = param2
|
176 |
+
|
177 |
+
@staticmethod
|
178 |
+
def example_method(param1, param2=None):
|
179 |
+
"""
|
180 |
+
Example method.
|
181 |
+
|
182 |
+
Parameters
|
183 |
+
----------
|
184 |
+
param1 : str
|
185 |
+
Description of param1.
|
186 |
+
param2 : int, optional
|
187 |
+
Description of param2. Defaults to None.
|
188 |
+
|
189 |
+
Returns
|
190 |
+
-------
|
191 |
+
bool
|
192 |
+
Outcome of the method's action.
|
193 |
+
"""
|
194 |
+
return bool(param1) and bool(param2)
|
195 |
+
```
|
196 |
+
|
197 |
+
This structure ensures clear, consistent, and comprehensive documentation of classes and functions, including proper
|
198 |
+
citation of external sources.
|
199 |
+
|
200 |
+
##### Type Annotation
|
201 |
+
|
202 |
+
Add type annotations to all functions using `Annotated` with descriptions:
|
203 |
+
|
204 |
+
Example:
|
205 |
+
|
206 |
+
```python
|
207 |
+
# Standard library imports
|
208 |
+
from typing import Annotated
|
209 |
+
|
210 |
+
|
211 |
+
def calculate_area(
|
212 |
+
radius: Annotated[float, "Radius of the circle"]
|
213 |
+
) -> Annotated[float, "Area of the circle"]:
|
214 |
+
"""
|
215 |
+
Calculate the area of a circle given its radius.
|
216 |
+
|
217 |
+
Parameters
|
218 |
+
----------
|
219 |
+
radius : float
|
220 |
+
Radius of the circle.
|
221 |
+
|
222 |
+
Returns
|
223 |
+
-------
|
224 |
+
float
|
225 |
+
Area of the circle.
|
226 |
+
|
227 |
+
Examples
|
228 |
+
--------
|
229 |
+
>>> calculate_area(5)
|
230 |
+
78.53999999999999
|
231 |
+
>>> calculate_area(0)
|
232 |
+
0.0
|
233 |
+
"""
|
234 |
+
if not isinstance(radius, (int, float)):
|
235 |
+
raise TypeError("Expected int or float for parameter 'radius'")
|
236 |
+
if radius < 0:
|
237 |
+
raise ValueError("Radius cannot be negative")
|
238 |
+
return 3.1416 * radius ** 2
|
239 |
+
|
240 |
+
```
|
241 |
+
|
242 |
+
##### Type Check
|
243 |
+
|
244 |
+
Add type check within functions to ensure the correctness of input parameters:
|
245 |
+
|
246 |
+
Example:
|
247 |
+
|
248 |
+
```python
|
249 |
+
# Standard library imports
|
250 |
+
from typing import Annotated
|
251 |
+
|
252 |
+
def add_numbers(
|
253 |
+
a: Annotated[int, "First integer"],
|
254 |
+
b: Annotated[int, "Second integer"]
|
255 |
+
) -> Annotated[int, "Sum of a and b"]:
|
256 |
+
"""
|
257 |
+
Add two integers and return the result.
|
258 |
+
|
259 |
+
Parameters
|
260 |
+
----------
|
261 |
+
a : int
|
262 |
+
First integer.
|
263 |
+
b : int
|
264 |
+
Second integer.
|
265 |
+
|
266 |
+
Returns
|
267 |
+
-------
|
268 |
+
int
|
269 |
+
The sum of `a` and `b`.
|
270 |
+
|
271 |
+
Examples
|
272 |
+
--------
|
273 |
+
>>> add_numbers(2, 3)
|
274 |
+
5
|
275 |
+
>>> add_numbers(-1, 5)
|
276 |
+
4
|
277 |
+
"""
|
278 |
+
if not isinstance(a, int):
|
279 |
+
raise TypeError("Expected int for parameter 'a'")
|
280 |
+
if not isinstance(b, int):
|
281 |
+
raise TypeError("Expected int for parameter 'b'")
|
282 |
+
return a + b
|
283 |
+
```
|
284 |
+
|
285 |
+
##### Doctest
|
286 |
+
|
287 |
+
Include doctest examples in docstrings using the `>>>` format:
|
288 |
+
|
289 |
+
Example:
|
290 |
+
|
291 |
+
```python
|
292 |
+
# Standard library imports
|
293 |
+
from typing import Annotated
|
294 |
+
|
295 |
+
def multiply(
|
296 |
+
a: Annotated[int, "First integer"],
|
297 |
+
b: Annotated[int, "Second integer"]
|
298 |
+
) -> Annotated[int, "Product of a and b"]:
|
299 |
+
"""
|
300 |
+
Multiply two integers and return the result.
|
301 |
+
|
302 |
+
Parameters
|
303 |
+
----------
|
304 |
+
a : int
|
305 |
+
First integer.
|
306 |
+
b : int
|
307 |
+
Second integer.
|
308 |
+
|
309 |
+
Returns
|
310 |
+
-------
|
311 |
+
int
|
312 |
+
The product of `a` and `b`.
|
313 |
+
|
314 |
+
Examples
|
315 |
+
--------
|
316 |
+
>>> multiply(2, 3)
|
317 |
+
6
|
318 |
+
>>> multiply(-1, 5)
|
319 |
+
-5
|
320 |
+
|
321 |
+
This is a doctest example.
|
322 |
+
"""
|
323 |
+
if not isinstance(a, int):
|
324 |
+
raise TypeError("Expected int for parameter 'a'")
|
325 |
+
if not isinstance(b, int):
|
326 |
+
raise TypeError("Expected int for parameter 'b'")
|
327 |
+
|
328 |
+
return a * b
|
329 |
+
```
|
330 |
+
|
331 |
+
> **INFO**
|
332 |
+
>
|
333 |
+
> *For more detail, please check*:
|
334 |
+
> - [doctest — Test interactive Python examples — Python 3.13.1 documentation](https://docs.python.org/3/library/doctest.html)
|
335 |
+
|
336 |
+
##### Main Execution
|
337 |
+
|
338 |
+
Add each file to `Name-Main` code script:
|
339 |
+
|
340 |
+
Example:
|
341 |
+
|
342 |
+
```python
|
343 |
+
# Standard library imports
|
344 |
+
from typing import Annotated
|
345 |
+
|
346 |
+
def example_function(
|
347 |
+
x: Annotated[int, "An integer parameter"]
|
348 |
+
) -> Annotated[int, "The square of x"]:
|
349 |
+
"""
|
350 |
+
Calculate the square of an integer.
|
351 |
+
|
352 |
+
Parameters
|
353 |
+
----------
|
354 |
+
x : int
|
355 |
+
The integer to be squared.
|
356 |
+
|
357 |
+
Returns
|
358 |
+
-------
|
359 |
+
int
|
360 |
+
The square of `x`.
|
361 |
+
|
362 |
+
Examples
|
363 |
+
--------
|
364 |
+
>>> example_function(5)
|
365 |
+
25
|
366 |
+
>>> example_function(-3)
|
367 |
+
9
|
368 |
+
"""
|
369 |
+
return x * x
|
370 |
+
|
371 |
+
if __name__ == "__main__":
|
372 |
+
value = 5
|
373 |
+
result = example_function(value)
|
374 |
+
print(f"The square of {value} is {result}.")
|
375 |
+
```
|
376 |
+
|
377 |
+
##### General
|
378 |
+
|
379 |
+
- **Always Print Outputs to the Terminal**
|
380 |
+
- Ensure that any significant results or status messages are displayed to the user via `print` statements.
|
381 |
+
- Consider adding an optional parameter (e.g., `verbose=True`) that controls whether to print the outputs. This way,
|
382 |
+
users can disable or enable printed outputs as needed.
|
383 |
+
|
384 |
+
- **Reduce Code Complexity if It Does Not Disrupt the Flow**
|
385 |
+
- Whenever possible, simplify or refactor functions, methods, and classes.
|
386 |
+
- Clear, straightforward logic is easier to maintain and less error-prone.
|
387 |
+
|
388 |
+
- **Keep Your Code Modular at All Times**
|
389 |
+
- Break down larger tasks into smaller, reusable functions or modules.
|
390 |
+
- Modular design improves readability, promotes code reuse, and simplifies testing and maintenance.
|
391 |
+
|
392 |
+
- **Use Base Classes if Classes Become Too Complex**
|
393 |
+
- If a class starts to grow unwieldy or complicated, consider extracting shared logic into a base (parent) class.
|
394 |
+
- Child classes can inherit from this base class, reducing duplication and making the code more organized.
|
395 |
+
|
396 |
+
### File Structure
|
397 |
+
|
398 |
+
Follow the [Default Project Template](https://github.com/bunyaminergen/DefaultProjectTemplate)'s File Structure
|
399 |
+
|
400 |
+
- Adhere to the predetermined file hierarchy and naming conventions defined in the Default Project Template.
|
401 |
+
- Review the existing layout in the repository to ensure your contributions align with the project’s organization.
|
402 |
+
|
403 |
+
### Commit Message Guidelines
|
404 |
+
|
405 |
+
- **Keep It Short and Concise:**
|
406 |
+
- The subject line (summary) should typically not exceed **50 characters**.
|
407 |
+
- If more details are needed, include them in the body of the message on a separate line.
|
408 |
+
|
409 |
+
- **Use Present Tense and Imperative Mood:**
|
410 |
+
- **Start your commit message with only of the following verbs** and then explain what you did:
|
411 |
+
- `Add`
|
412 |
+
- `Fix`
|
413 |
+
- `Remove` or `Delete`
|
414 |
+
- `Update`
|
415 |
+
- `Test`
|
416 |
+
- `Refactor`
|
417 |
+
- Messages should use the present tense and imperative mood.
|
418 |
+
- **Examples:**
|
419 |
+
- `Add user authentication`
|
420 |
+
- `Fix bug in payment processing`
|
421 |
+
- `Remove unused dependencies`
|
422 |
+
|
423 |
+
- **Separate Subject and Details:**
|
424 |
+
- The first line (subject) should be short and descriptive.
|
425 |
+
- Leave a blank line between the subject and the detailed description (if needed).
|
426 |
+
- **Example:**
|
427 |
+
|
428 |
+
```text
|
429 |
+
Fix login issue
|
430 |
+
|
431 |
+
Updated the authentication service to handle null values in the session token.
|
432 |
+
```
|
433 |
+
|
434 |
+
- **Mistakes to Avoid:**
|
435 |
+
- **Vague Messages:**
|
436 |
+
- *Bad Example:* `Fix stuff`, `Update files`, `Work done`.
|
437 |
+
- **Combining Multiple Changes in One Commit:**
|
438 |
+
- Avoid bundling unrelated changes into a single commit.
|
439 |
+
- **Copy-Paste Descriptions:**
|
440 |
+
- Ensure that the commit message is directly relevant to the change.
|
441 |
+
|
442 |
+
- **Benefits of Good Commit Messages:**
|
443 |
+
- A well-written commit history makes the project easier to understand.
|
444 |
+
- It simplifies debugging and troubleshooting.
|
445 |
+
- It improves collaboration within the team by providing clear and meaningful information.
|
446 |
+
|
447 |
+
### Branches
|
448 |
+
|
449 |
+
To maintain consistency across all branches, follow these guidelines:
|
450 |
+
|
451 |
+
- **Start with one of the following action keywords in lowercase:**
|
452 |
+
- `add`
|
453 |
+
- `fix`
|
454 |
+
- `remove` or `delete`
|
455 |
+
- `update`
|
456 |
+
- `test`
|
457 |
+
- `refactor`
|
458 |
+
- Use hyphens (`-`) to separate words in the branch name.
|
459 |
+
- Avoid special characters, spaces, or uppercase letters.
|
460 |
+
- Keep branch names concise but descriptive.
|
461 |
+
|
462 |
+
**Example Branch Names:**
|
463 |
+
|
464 |
+
- `add-new-release`
|
465 |
+
- `fix-critical-bug`
|
466 |
+
- `remove-unused-dependencies`
|
467 |
+
- `update-api-endpoints`
|
468 |
+
- `test-api-performance`
|
469 |
+
- `refactor-code-structure`
|
470 |
+
|
471 |
+
Please push all development work to the `develop` branch. Once the work on your branch is finished, merge it into
|
472 |
+
`develop` and then delete the branch to keep the repository clean.
|
473 |
+
|
474 |
+
**Important:** Please only create branches that begin with the prefixes listed below. If you would like to propose a new
|
475 |
+
prefix, kindly open an issue on GitHub.
|
476 |
+
|
477 |
+
##### Bug Branches
|
478 |
+
|
479 |
+
Use the `bugfix/` prefix for bug fixes discovered during development or testing.
|
480 |
+
Examples:
|
481 |
+
|
482 |
+
- `bugfix/fix-typo-in-readme`
|
483 |
+
- `bugfix/null-pointer-exception`
|
484 |
+
|
485 |
+
##### Feature Branches
|
486 |
+
|
487 |
+
Use the `feature/` prefix for new features or enhancements.
|
488 |
+
Examples:
|
489 |
+
|
490 |
+
- `feature/add-login`
|
491 |
+
- `feature/update-dashboard`
|
492 |
+
- `feature/fix-bug-123`
|
493 |
+
|
494 |
+
##### Hotfix Branches
|
495 |
+
|
496 |
+
Use the `hotfix/` prefix for critical fixes that need immediate attention in production.
|
497 |
+
Example:
|
498 |
+
|
499 |
+
- `hotfix/fix-security-issue`
|
500 |
+
|
501 |
+
##### Docfix Branches
|
502 |
+
|
503 |
+
Use the `docfix/` prefix for changes regarding documentation.
|
504 |
+
Example:
|
505 |
+
|
506 |
+
- `docfix/add-readme-to-artitecture-section`
|
507 |
+
|
508 |
+
##### Test Branches
|
509 |
+
|
510 |
+
Use the `test/` prefix for branches that focus on writing or updating tests, or conducting specific test-related work.
|
511 |
+
Examples:
|
512 |
+
|
513 |
+
- `test/add-integration-tests`
|
514 |
+
- `test/refactor-unit-tests`
|
515 |
+
- `test/performance-testing`
|
516 |
+
|
517 |
+
##### Experiment Branches
|
518 |
+
|
519 |
+
Use the `experiment/` prefix for experimental or proof-of-concept work.
|
520 |
+
Example:
|
521 |
+
|
522 |
+
- `experiment/improve-cache`
|
523 |
+
|
524 |
+
---
|
525 |
+
|
526 |
+
### File Naming Convention
|
527 |
+
|
528 |
+
This section explains how packages and modules should be named in this project.
|
529 |
+
|
530 |
+
---
|
531 |
+
|
532 |
+
##### Package & Module Naming
|
533 |
+
|
534 |
+
The following rules apply to **both** packages and modules. To simplify these guidelines, the term **"file"** will be
|
535 |
+
used as a generic reference to either a package or a module name.
|
536 |
+
|
537 |
+
- **Single or Concise Compound Words:**
|
538 |
+
- Whenever possible, each file name should consist of **a single word** or **a short concatenation of words** (
|
539 |
+
written together).
|
540 |
+
- Use **lowercase letters** only, and **do not** use underscores (`_`).
|
541 |
+
*(Although PEP 8 allows snake_case for modules, we do not prefer it in this project.)*
|
542 |
+
- If more than one word is necessary, write them **together** (e.g., `datautils`, `webparser`).
|
543 |
+
|
544 |
+
- **Consistent Single-Word Usage:**
|
545 |
+
- Especially for package names, aim to keep them to **one word** whenever possible. If multiple words are necessary,
|
546 |
+
the package name should remain **short and clear**.
|
547 |
+
|
548 |
+
- **Parent (Package) and Sub-Component (Module) Logic:**
|
549 |
+
- Use broader, more general names for packages (the “parent”).
|
550 |
+
- For modules (the “child”), use more specific names within the package to reflect their functionality.
|
551 |
+
|
552 |
+
- **Examples:**
|
553 |
+
- **Packages**
|
554 |
+
- `utils`
|
555 |
+
- `model`
|
556 |
+
- **Modules**
|
557 |
+
- `gridsearch.py`
|
558 |
+
- `convolution.py`
|
559 |
+
- **Parent–Child (Directory Structure) Example**
|
560 |
+
- `src/model/backbone.py`
|
561 |
+
- `src/utils/log/manager.py`
|
562 |
+
|
563 |
+
- **Bad Examples:**
|
564 |
+
- **Packages**
|
565 |
+
- `data_reader` *(underscores are discouraged)*
|
566 |
+
- **Modules**
|
567 |
+
- `grid_search.py` *(underscores are discouraged)*
|
568 |
+
- **Parent–Child (Directory Structure) Example**
|
569 |
+
- `src/train/training.py` *(names are too similar or redundant)*
|
570 |
+
|
571 |
+
---
|
572 |
+
|
573 |
+
##### Test Files
|
574 |
+
|
575 |
+
1. **Using the `test_` Prefix:**
|
576 |
+
- For test files, prepend `test_` to the **module** name being tested.
|
577 |
+
- **Example:** If the module name is `dataprocess.py`, then the test file should be named `test_dataprocess.py`.
|
578 |
+
|
579 |
+
> **INFO**
|
580 |
+
> *For more details, please check:*
|
581 |
+
> - [PEP 8 – Style Guide for Python Code | peps.python.org](https://peps.python.org/pep-0008/#:~:text=Modules%20should%20have%20short%2C%20all,use%20of%20underscores%20is%20discouraged)
|
582 |
+
> - [PEP 423 – Naming conventions and recipes related to packaging | peps.python.org](https://peps.python.org/pep-0423/#follow-pep-8-for-syntax-of-package-and-module-names)
|
583 |
+
|
584 |
+
---
|
585 |
+
|
586 |
+
### Versioning, Release, Tag
|
587 |
+
|
588 |
+
- When numbering versions, releases, or tags, **only use prime numbers** (e.g., 3, 5, 7, 11, 13...).
|
589 |
+
- **Do not** use 2 (even though it is prime) or any non-prime numbers (4, 6, 8, 9, 10...).
|
590 |
+
|
591 |
+
#### Examples
|
592 |
+
|
593 |
+
**Good Examples** (using only prime numbers, excluding 2):
|
594 |
+
|
595 |
+
- **Tag**: `v3`
|
596 |
+
- **Release**: `v3.5.7`
|
597 |
+
- **Version**: `5.7.11`
|
598 |
+
|
599 |
+
**Bad Examples**:
|
600 |
+
|
601 |
+
- **Tag**: `v2` *(2 is prime but disallowed in this project)*
|
602 |
+
- **Release**: `v1.2.3` *(1 is not prime, 2 is disallowed, 3 is prime but the rest are invalid)*
|
603 |
+
- **Version**: `4.6.8` *(4, 6, 8 are not prime)*
|
604 |
+
|
605 |
+
---
|
606 |
+
|
.docs/documentation/RESOURCES.md
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Resources
|
2 |
+
|
3 |
+
---
|
4 |
+
|
5 |
+
## Github
|
6 |
+
|
7 |
+
- [NeMo](https://github.com/NVIDIA/NeMo)
|
8 |
+
- [Llama](https://github.com/facebookresearch/llama)
|
9 |
+
- [Demucs](https://github.com/facebookresearch/demucs)
|
10 |
+
- [Whisper](https://github.com/openai/whisper)
|
11 |
+
- [Whisper NeMo Diarization](https://github.com/MahmoudAshraf97/whisper-diarization)
|
12 |
+
- [Text to speech alignment using CTC forced alignment](https://github.com/MahmoudAshraf97/ctc-forced-aligner)
|
13 |
+
- [Utilities intended for use with Llama models.](https://github.com/meta-llama/llama-models/)
|
14 |
+
- [Llama Recipes: Examples to get started using the Llama models from Meta](https://github.com/meta-llama/llama-recipes)
|
15 |
+
- [timsainb/noisereduce: Noise reduction in python using spectral gating](https://github.com/timsainb/noisereduce/)
|
16 |
+
- [pyannote/pyannote-audio: Neural building blocks for speaker diarization](https://github.com/pyannote/pyannote-audio)
|
17 |
+
- [microsoft/DNS-Challenge: This repo contains the scripts, models, and required files for the Deep Noise Suppression (DNS) Challenge.](https://github.com/microsoft/DNS-Challenge)
|
18 |
+
- [WenzheLiu-Speech/awesome-speech-enhancement: speech enhancement\speech seperation\sound source localization](https://github.com/WenzheLiu-Speech/awesome-speech-enhancement)
|
19 |
+
- [nanahou/Awesome-Speech-Enhancement: A tutorial for Speech Enhancement researchers and practitioners. The purpose of this repo is to organize the world’s resources for speech enhancement and make them universally accessible and useful.](https://github.com/nanahou/Awesome-Speech-Enhancement)
|
20 |
+
- [jonashaag/speech-enhancement: Collection of papers, datasets and tools on the topic of Speech Dereverberation and Speech Enhancement](https://github.com/jonashaag/speech-enhancement)
|
21 |
+
- [yxlu-0102/MP-SENet: Explicit Estimation of Magnitude and Phase Spectra in Parallel for High-Quality Speech Enhancement](https://github.com/yxlu-0102/MP-SENet)
|
22 |
+
- [Explicit Estimation of Magnitude and Phase Spectra in Parallel for High-Quality Speech Enhancement](https://yxlu-0102.github.io/MP-SENet/)
|
23 |
+
- [## SUPERSEDED: THIS DATASET HAS BEEN REPLACED. ## Noisy speech database for training speech enhancement algorithms and TTS models](https://datashare.ed.ac.uk/handle/10283/1942)
|
24 |
+
|
25 |
+
---
|
26 |
+
|
27 |
+
## Web
|
28 |
+
|
29 |
+
- [Llama](https://www.llama.com/)
|
30 |
+
- [Download Llama](https://www.llama.com/llama-downloads/)
|
31 |
+
- [Llama 3.2 Requirements](https://llamaimodel.com/requirements-3-2/)
|
32 |
+
- [Average handle time (AHT): Formula and tips for improvement](https://www.zendesk.com/blog/average-handle-time/)
|
33 |
+
|
34 |
+
---
|
35 |
+
|
36 |
+
## Notebooks
|
37 |
+
|
38 |
+
- [Hybrid Demucs Music Source Separation](https://colab.research.google.com/drive/1dC9nVxk3V_VPjUADsnFu8EiT-xnU1tGH)
|
39 |
+
|
40 |
+
---
|
41 |
+
|
42 |
+
## PyPI
|
43 |
+
|
44 |
+
- [demucs](https://pypi.org/project/demucs/)
|
45 |
+
- [MPSENet](https://pypi.org/project/MPSENet/)
|
46 |
+
|
47 |
+
---
|
48 |
+
|
49 |
+
## Errors
|
50 |
+
|
51 |
+
- [`The file is already fully retrieved; nothing to do.`](https://github.com/facebookresearch/llama/issues/760)
|
52 |
+
|
53 |
+
---
|
54 |
+
|
55 |
+
## Paper
|
56 |
+
|
57 |
+
- [Dual-Path Transformer Network: Direct Context-Aware Modeling for End-to-End Monaural Speech Separation](https://arxiv.org/abs/2007.13975)
|
58 |
+
- [MP-SENet: A Speech Enhancement Model with Parallel Denoising of Magnitude and Phase Spectra](https://arxiv.org/abs/2305.13686)
|
59 |
+
- [FINALLY: fast and universal speech enhancement with studio-like quality](https://arxiv.org/abs/2410.05920)
|
60 |
+
- [Explicit Estimation of Magnitude and Phase Spectra in Parallel for High-Quality Speech Enhancement](https://arxiv.org/abs/2308.08926)
|
61 |
+
- [\[2410.08235\] A Recurrent Neural Network Approach to the Answering Machine Detection Problem](https://arxiv.org/abs/2410.08235)
|
62 |
+
|
63 |
+
---
|
64 |
+
|
65 |
+
## Youtube
|
66 |
+
|
67 |
+
- [A Course on Speech Enhancement](https://www.youtube.com/playlist?list=PLO9nFIQB53_DU8o0fToNdNFdZuDxD9fAN)
|
68 |
+
- [COMS 4995 Final on Speech Enhancement](https://www.youtube.com/watch?v=uRwlSh1FMzc&t=74s)
|
69 |
+
- [Achieving Studio-Quality Speech with Generative AI](https://www.youtube.com/watch?v=UxbEjpLMU8s)
|
70 |
+
- [How to Fix Bad Podcast Audio](https://www.youtube.com/watch?v=0mPkPQNHsZc)
|
71 |
+
- [Speech Enhancement for Cochlear Implant Recipients Using Deep Complex Convolution Transformer With F](https://www.youtube.com/watch?v=i1qTgjMtS2Y)
|
72 |
+
- [Vibravox: A Dataset of French Speech Captured with Body-conduction Audio Sensors](https://www.youtube.com/watch?v=4jiQdotz6qY)
|
73 |
+
- [2024 종합설계 3팀 2차, Neural Network for Speech Enhancement](https://www.youtube.com/watch?v=yOfTYuc9FEQ)
|
74 |
+
- [MIAI Deeptails Seminar : Generative Models as Data-driven Priors for Speech Enhancement](https://www.youtube.com/watch?v=XSLgUsgyzUA)
|
75 |
+
- [Hardware Efficient Speech Enhancement With Noise Aware Multi Target Deep Learning](https://www.youtube.com/watch?v=qO6JqDUQlsI)
|
76 |
+
- [Diffusion Models for Speech Enhancement | Julius Richter](https://www.youtube.com/watch?v=HMrs6YWDl5M)
|
77 |
+
- [Speech Enhancement: Basics & Key Details](https://www.youtube.com/watch?v=5kItH2pq_3E)
|
78 |
+
- [Guided Speech Enhancement Network (ICASSP 2023)](https://www.youtube.com/watch?v=JoDqXkAjlh4)
|
79 |
+
- [VSANet: Real-time Speech Enhancement Based on Voice Activity Detection and Causal Spatial Attention](https://www.youtube.com/watch?v=GP39vFA2E48)
|
80 |
+
- [Research intern talk: Unified speech enhancement approach for speech degradation & noise suppression](https://www.youtube.com/watch?v=_ggfv6eMIJs)
|
81 |
+
- [Magnitude and phase spectrum with example](https://www.youtube.com/watch?v=MFOjUgafq0k)
|
82 |
+
- [Deep Learning In Audio for Absolute Beginners: From No Experience & No Datasets to a Deployed Model](https://www.youtube.com/watch?v=sqrah49GUkI)
|
83 |
+
- [Look Once to Hear: Target Speech Hearing with Noisy Examples](https://www.youtube.com/watch?v=V-XCfnjfQmM)
|
84 |
+
|
85 |
+
---
|
86 |
+
|
87 |
+
## Wikipedia
|
88 |
+
|
89 |
+
- [Speech enhancement](https://en.m.wikipedia.org/wiki/Speech_enhancement)
|
90 |
+
|
91 |
+
---
|
92 |
+
|
93 |
+
## Hugging Face
|
94 |
+
|
95 |
+
- [Models(asteroid)](https://huggingface.co/models?library=asteroid)
|
96 |
+
- [cankeles/DPTNet_WHAMR_enhsingle_16k](https://huggingface.co/cankeles/DPTNet_WHAMR_enhsingle_16k)
|
97 |
+
- [JacobLinCool/MP-SENet-VB](https://huggingface.co/JacobLinCool/MP-SENet-VB)
|
98 |
+
- [JacobLinCool/MP-SENet-DNS](https://huggingface.co/JacobLinCool/MP-SENet-DNS)
|
99 |
+
- [ENOT-AutoDL/MP-SENet](https://huggingface.co/ENOT-AutoDL/MP-SENet)
|
100 |
+
|
101 |
+
---
|
102 |
+
|
103 |
+
## Web
|
104 |
+
|
105 |
+
- [Dual-Path Transformer Network: Direct Context-Aware Modeling for End-to-End Monaural Speech Separation](https://paperswithcode.com/paper/dual-path-transformer-network-direct-context-1)
|
106 |
+
- [The Audio Developer Conference - ADC is an annual event celebrating all audio development technologies, from music applications and game audio to audio processing and embedded systems.](https://audio.dev/)
|
107 |
+
- [Look Once to Hear: Target Speech Hearing with Noisy Examples - CHI '24](https://programs.sigchi.org/chi/2024/program/content/147319)
|
108 |
+
- [Reinforcement Learning Based Speech Enhancement for Robust Speech Recognition > Introduction | Class Central Classroom](https://www.classcentral.com/classroom/youtube-reinforcement-learning-based-speech-enhancement-for-robust-speech-recognition-131999)
|
109 |
+
- [Sound classification with YAMNet TensorFlow Hub](https://www.tensorflow.org/hub/tutorials/yamnet)
|
110 |
+
- [DEEP-VOICE: DeepFake Voice Recognition Dataset | Papers With Code](https://paperswithcode.com/dataset/deep-voice-deepfake-voice-recognition)
|
111 |
+
|
112 |
+
---
|
113 |
+
|
114 |
+
## Dataset
|
115 |
+
|
116 |
+
- [VoiceBank+DEMAND](https://datashare.ed.ac.uk/handle/10283/1942)
|
117 |
+
- [VoiceBank+DEMAND](https://drive.google.com/drive/folders/19I_thf6F396y5gZxLTxYIojZXC0Ywm8l)
|
118 |
+
|
119 |
+
---
|
.docs/img/Callytics.drawio
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/25.0.1 Chrome/128.0.6613.186 Electron/32.2.6 Safari/537.36" version="25.0.1">
|
2 |
+
<diagram name="Page-1" id="mQKUGW6_SND0Kw_IrtOi">
|
3 |
+
<mxGraphModel dx="1829" dy="896" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="1600" pageHeight="900" math="0" shadow="0">
|
4 |
+
<root>
|
5 |
+
<mxCell id="0" />
|
6 |
+
<mxCell id="1" parent="0" />
|
7 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;flowAnimation=1;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-2" target="5rAtEOWpySoy4L2wUreW-3">
|
8 |
+
<mxGeometry relative="1" as="geometry">
|
9 |
+
<Array as="points">
|
10 |
+
<mxPoint x="70" y="453" />
|
11 |
+
</Array>
|
12 |
+
</mxGeometry>
|
13 |
+
</mxCell>
|
14 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-2" value="<i><b>Input<br>(Audio File)</b></i>" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fillColor=default;strokeWidth=3;" vertex="1" parent="1">
|
15 |
+
<mxGeometry x="20" y="230" width="105" height="105" as="geometry" />
|
16 |
+
</mxCell>
|
17 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-3" value="" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;rotation=90;strokeWidth=3;fillColor=default;" vertex="1" parent="1">
|
18 |
+
<mxGeometry x="857.33" y="-321.46" width="141.5" height="1578.78" as="geometry" />
|
19 |
+
</mxCell>
|
20 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-4" style="rounded=0;orthogonalLoop=1;jettySize=auto;html=1;flowAnimation=1;endArrow=none;endFill=0;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-5" target="5rAtEOWpySoy4L2wUreW-8">
|
21 |
+
<mxGeometry relative="1" as="geometry" />
|
22 |
+
</mxCell>
|
23 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-5" value="<div><b>Dialogue&nbsp;<br>Detection</b></div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
24 |
+
<mxGeometry x="160" y="422.5" width="100" height="60" as="geometry" />
|
25 |
+
</mxCell>
|
26 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-6" value="<font style="font-size: 9px;"><i>Pyannote</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
27 |
+
<mxGeometry x="176" y="482.94" width="68" height="37" as="geometry" />
|
28 |
+
</mxCell>
|
29 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=none;endFill=0;flowAnimation=1;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-8" target="5rAtEOWpySoy4L2wUreW-10">
|
30 |
+
<mxGeometry relative="1" as="geometry" />
|
31 |
+
</mxCell>
|
32 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-8" value="<b>Speech Enhancement</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
33 |
+
<mxGeometry x="270" y="422.94" width="100" height="60" as="geometry" />
|
34 |
+
</mxCell>
|
35 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-9" value="<font size="1"><i>MP-SENet</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
36 |
+
<mxGeometry x="286" y="482.94" width="68" height="37" as="geometry" />
|
37 |
+
</mxCell>
|
38 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-10" value="<b>Vocal</b><div><b>Seperation</b></div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
39 |
+
<mxGeometry x="380" y="422.5" width="100" height="60" as="geometry" />
|
40 |
+
</mxCell>
|
41 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-11" value="<font style="font-size: 9px;"><i>Demucs</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
42 |
+
<mxGeometry x="396" y="482.5" width="68" height="37" as="geometry" />
|
43 |
+
</mxCell>
|
44 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-12" value="<b>Transcription</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
45 |
+
<mxGeometry x="494" y="422.94" width="100" height="60" as="geometry" />
|
46 |
+
</mxCell>
|
47 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-13" value="<font style="font-size: 9px;"><i>Faster Whisper</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
48 |
+
<mxGeometry x="510" y="482.94" width="68" height="37" as="geometry" />
|
49 |
+
</mxCell>
|
50 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-14" value="<b>Forced Alignment</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
51 |
+
<mxGeometry x="610" y="422.5" width="100" height="60" as="geometry" />
|
52 |
+
</mxCell>
|
53 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-15" value="<div style=""><i style="font-size: 9px; background-color: initial; line-height: 100%;">ctc forced aligner</i></div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;align=center;" vertex="1" parent="1">
|
54 |
+
<mxGeometry x="626" y="482.5" width="68" height="37" as="geometry" />
|
55 |
+
</mxCell>
|
56 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;flowAnimation=1;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-12" target="5rAtEOWpySoy4L2wUreW-14">
|
57 |
+
<mxGeometry relative="1" as="geometry" />
|
58 |
+
</mxCell>
|
59 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-17" value="<b>Diarization</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
60 |
+
<mxGeometry x="730" y="422.5" width="100" height="60" as="geometry" />
|
61 |
+
</mxCell>
|
62 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-18" value="<font size="1"><i>Nvidia Nemo</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
63 |
+
<mxGeometry x="746" y="482.5" width="68" height="37" as="geometry" />
|
64 |
+
</mxCell>
|
65 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-19" value="<b>Speaker Role<br>Classification</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
66 |
+
<mxGeometry x="850" y="422.94" width="100" height="60" as="geometry" />
|
67 |
+
</mxCell>
|
68 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-20" value="<font size="1"><i>LLM</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
69 |
+
<mxGeometry x="866" y="482.94" width="68" height="37" as="geometry" />
|
70 |
+
</mxCell>
|
71 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;flowAnimation=1;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-17" target="5rAtEOWpySoy4L2wUreW-19">
|
72 |
+
<mxGeometry relative="1" as="geometry" />
|
73 |
+
</mxCell>
|
74 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-22" value="<b>Sentiment</b><div><b>Analysis</b></div>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
75 |
+
<mxGeometry x="970" y="422.94" width="100" height="60" as="geometry" />
|
76 |
+
</mxCell>
|
77 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-23" value="<font size="1"><i>LLM</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
78 |
+
<mxGeometry x="986" y="485.44" width="68" height="37" as="geometry" />
|
79 |
+
</mxCell>
|
80 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-24" value="<b>Profanity Word Detection</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
81 |
+
<mxGeometry x="1090" y="422.5" width="100" height="60" as="geometry" />
|
82 |
+
</mxCell>
|
83 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-25" value="<font size="1"><i>LLM</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
84 |
+
<mxGeometry x="1106" y="482.5" width="68" height="37" as="geometry" />
|
85 |
+
</mxCell>
|
86 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-26" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;flowAnimation=1;endArrow=none;endFill=0;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-22" target="5rAtEOWpySoy4L2wUreW-24">
|
87 |
+
<mxGeometry relative="1" as="geometry" />
|
88 |
+
</mxCell>
|
89 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-27" value="<b>Summary</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
90 |
+
<mxGeometry x="1213" y="422.5" width="100" height="60" as="geometry" />
|
91 |
+
</mxCell>
|
92 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-28" value="<font size="1"><i>LLM</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
93 |
+
<mxGeometry x="1229" y="482.5" width="68" height="37" as="geometry" />
|
94 |
+
</mxCell>
|
95 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-29" value="<b>Conflict Detection</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
96 |
+
<mxGeometry x="1330" y="422.5" width="100" height="60" as="geometry" />
|
97 |
+
</mxCell>
|
98 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-30" value="<font size="1"><i>LLM</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
99 |
+
<mxGeometry x="1346" y="482.94" width="68" height="37" as="geometry" />
|
100 |
+
</mxCell>
|
101 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-31" value="<b>Topic Detection</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
102 |
+
<mxGeometry x="1450" y="422.94" width="100" height="60" as="geometry" />
|
103 |
+
</mxCell>
|
104 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-32" value="<font size="1"><i>LLM</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
105 |
+
<mxGeometry x="1466" y="482.94" width="68" height="37" as="geometry" />
|
106 |
+
</mxCell>
|
107 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-33" value="<b>Storage</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.stored_data;whiteSpace=wrap;spacingLeft=8;spacingRight=4;spacingBottom=3;direction=west;" vertex="1" parent="1">
|
108 |
+
<mxGeometry x="1570" y="422.5" width="100" height="60" as="geometry" />
|
109 |
+
</mxCell>
|
110 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-34" value="<font size="1"><i>Database</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
111 |
+
<mxGeometry x="1586" y="485.44" width="68" height="37" as="geometry" />
|
112 |
+
</mxCell>
|
113 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-35" value="<b>Monitoring&nbsp;<br></b><div><b>&amp;&nbsp;</b></div><div><b>Alarms</b></div>" style="verticalLabelPosition=middle;verticalAlign=middle;html=1;shape=mxgraph.basic.three_corner_round_rect;dx=6;whiteSpace=wrap;labelPosition=center;align=center;" vertex="1" parent="1">
|
114 |
+
<mxGeometry x="1760" y="422.5" width="140" height="90" as="geometry" />
|
115 |
+
</mxCell>
|
116 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-36" value="<font size="1"><i>Grafana</i></font>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.document2;whiteSpace=wrap;size=0.25;" vertex="1" parent="1">
|
117 |
+
<mxGeometry x="1796" y="512.94" width="68" height="37" as="geometry" />
|
118 |
+
</mxCell>
|
119 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-37" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=classic;endFill=1;flowAnimation=1;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-3" target="5rAtEOWpySoy4L2wUreW-35">
|
120 |
+
<mxGeometry relative="1" as="geometry" />
|
121 |
+
</mxCell>
|
122 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-38" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;flowAnimation=1;endArrow=none;endFill=0;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-10" target="5rAtEOWpySoy4L2wUreW-12">
|
123 |
+
<mxGeometry relative="1" as="geometry" />
|
124 |
+
</mxCell>
|
125 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-39" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;flowAnimation=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="5rAtEOWpySoy4L2wUreW-14" target="5rAtEOWpySoy4L2wUreW-17">
|
126 |
+
<mxGeometry relative="1" as="geometry">
|
127 |
+
<mxPoint x="710" y="452.41" as="sourcePoint" />
|
128 |
+
<mxPoint x="733" y="452.41" as="targetPoint" />
|
129 |
+
</mxGeometry>
|
130 |
+
</mxCell>
|
131 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-40" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;flowAnimation=1;" edge="1" parent="1">
|
132 |
+
<mxGeometry relative="1" as="geometry">
|
133 |
+
<mxPoint x="950" y="452.4" as="sourcePoint" />
|
134 |
+
<mxPoint x="977" y="452.4" as="targetPoint" />
|
135 |
+
</mxGeometry>
|
136 |
+
</mxCell>
|
137 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-41" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;flowAnimation=1;endArrow=none;endFill=0;" edge="1" parent="1">
|
138 |
+
<mxGeometry relative="1" as="geometry">
|
139 |
+
<mxPoint x="1190" y="452.87" as="sourcePoint" />
|
140 |
+
<mxPoint x="1217" y="452.87" as="targetPoint" />
|
141 |
+
</mxGeometry>
|
142 |
+
</mxCell>
|
143 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-42" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;flowAnimation=1;" edge="1" parent="1">
|
144 |
+
<mxGeometry relative="1" as="geometry">
|
145 |
+
<mxPoint x="1430" y="452.84" as="sourcePoint" />
|
146 |
+
<mxPoint x="1454" y="452.84" as="targetPoint" />
|
147 |
+
</mxGeometry>
|
148 |
+
</mxCell>
|
149 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-43" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;flowAnimation=1;" edge="1" parent="1">
|
150 |
+
<mxGeometry relative="1" as="geometry">
|
151 |
+
<mxPoint x="1313" y="452.45" as="sourcePoint" />
|
152 |
+
<mxPoint x="1337" y="452.45" as="targetPoint" />
|
153 |
+
</mxGeometry>
|
154 |
+
</mxCell>
|
155 |
+
<mxCell id="5rAtEOWpySoy4L2wUreW-44" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.93;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;flowAnimation=1;" edge="1" parent="1">
|
156 |
+
<mxGeometry relative="1" as="geometry">
|
157 |
+
<mxPoint x="1550" y="452.45" as="sourcePoint" />
|
158 |
+
<mxPoint x="1574" y="452.45" as="targetPoint" />
|
159 |
+
</mxGeometry>
|
160 |
+
</mxCell>
|
161 |
+
</root>
|
162 |
+
</mxGraphModel>
|
163 |
+
</diagram>
|
164 |
+
</mxfile>
|
.docs/img/Callytics.gif
ADDED
![]() |
Git LFS Details
|
.docs/img/Callytics.png
ADDED
![]() |
Git LFS Details
|
.docs/img/Callytics.svg
ADDED
|
.docs/img/CallyticsIcon.png
ADDED
![]() |
Git LFS Details
|
.docs/img/callyticsDemo.gif
ADDED
![]() |
Git LFS Details
|
.docs/img/database.png
ADDED
![]() |
Git LFS Details
|
.docs/presentation/CallyticsPresentationEN.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eeeb65cf46a72a930f855b561b403f6e9cd42b5fb178f8aa7fa0fa97c3d42afd
|
3 |
+
size 16425335
|
.gitattributes
CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
# CallyticsDemo
|
37 |
+
*.pdf filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
39 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
40 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
41 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
* @bunyaminergen
|
.gitignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Directory
|
2 |
+
.idea
|
3 |
+
.temp
|
4 |
+
.agile
|
5 |
+
.data/input
|
6 |
+
|
7 |
+
# Extension
|
8 |
+
*.env
|
LICENSE
ADDED
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<https://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
README.md
CHANGED
@@ -1,14 +1,546 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
---
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div align="center">
|
2 |
+
<img src=".docs/img/CallyticsIcon.png" alt="CallyticsLogo" width="200">
|
3 |
+
|
4 |
+

|
5 |
+

|
6 |
+

|
7 |
+

|
8 |
+
|
9 |
+
[](https://linkedin.com/in/bunyaminergen)
|
10 |
+
|
11 |
+
# Callytics
|
12 |
+
|
13 |
+
`Callytics` is an advanced call analytics solution that leverages speech recognition and large language models (LLMs)
|
14 |
+
technologies to analyze phone conversations from customer service and call centers. By processing both the
|
15 |
+
audio and text of each call, it provides insights such as sentiment analysis, topic detection, conflict detection,
|
16 |
+
profanity word detection and summary. These cutting-edge techniques help businesses optimize customer interactions,
|
17 |
+
identify areas for improvement, and enhance overall service quality.
|
18 |
+
|
19 |
+
When an audio file is placed in the `.data/input` directory, the entire pipeline automatically starts running, and the
|
20 |
+
resulting data is inserted into the database.
|
21 |
+
|
22 |
+
**Note**: _This is only a `v1.1.0` version; many new features will be added, models
|
23 |
+
will be fine-tuned or trained from scratch, and various optimization efforts will be applied. For more information,
|
24 |
+
you can check out the [Upcoming](#upcoming) section._
|
25 |
+
|
26 |
+
**Note**: _If you would like to contribute to this repository,
|
27 |
+
please read the [CONTRIBUTING](.docs/documentation/CONTRIBUTING.md) first._
|
28 |
+
|
29 |
+
</div>
|
30 |
+
|
31 |
+
---
|
32 |
+
|
33 |
+
### Table of Contents
|
34 |
+
|
35 |
+
- [Prerequisites](#prerequisites)
|
36 |
+
- [Architecture](#architecture)
|
37 |
+
- [Math And Algorithm](#math-and-algorithm)
|
38 |
+
- [Features](#features)
|
39 |
+
- [Demo](#demo)
|
40 |
+
- [Installation](#installation)
|
41 |
+
- [File Structure](#file-structure)
|
42 |
+
- [Database Structure](#database-structure)
|
43 |
+
- [Datasets](#datasets)
|
44 |
+
- [Version Control System](#version-control-system)
|
45 |
+
- [Upcoming](#upcoming)
|
46 |
+
- [Documentations](#documentations)
|
47 |
+
- [License](#licence)
|
48 |
+
- [Links](#links)
|
49 |
+
- [Team](#team)
|
50 |
+
- [Contact](#contact)
|
51 |
+
- [Citation](#citation)
|
52 |
+
|
53 |
+
---
|
54 |
+
|
55 |
+
### Prerequisites
|
56 |
+
|
57 |
+
##### General
|
58 |
+
|
59 |
+
- `Python 3.11` _(or above)_
|
60 |
+
|
61 |
+
##### Llama
|
62 |
+
|
63 |
+
- `GPU (min 24GB)` _(or above)_
|
64 |
+
- `Hugging Face Credentials (Account, Token)`
|
65 |
+
- `Llama-3.2-11B-Vision-Instruct` _(or above)_
|
66 |
+
|
67 |
+
##### OpenAI
|
68 |
+
|
69 |
+
- `GPU (min 12GB)` _(for other process such as `faster whisper` & `NeMo`)_
|
70 |
+
- At least one of the following is required:
|
71 |
+
- `OpenAI Credentials (Account, API Key)`
|
72 |
+
- `Azure OpenAI Credentials (Account, API Key, API Base URL)`
|
73 |
+
|
74 |
+
---
|
75 |
+
|
76 |
+
### Architecture
|
77 |
+
|
78 |
+

|
79 |
+
|
80 |
+
---
|
81 |
+
|
82 |
+
### Math and Algorithm
|
83 |
+
|
84 |
+
This section describes the mathematical models and algorithms used in the project.
|
85 |
+
|
86 |
+
_**Note**: The mathematical concepts and algorithms specific to this repository, rather than the models used, will be
|
87 |
+
provided in this section. Please refer to the `RESOURCES` under the [Documentations](#documentations) section for the
|
88 |
+
repositories and models utilized or referenced._
|
89 |
+
|
90 |
+
##### Silence Duration Calculation
|
91 |
+
|
92 |
+
The silence durations are derived from the time intervals between speech segments:
|
93 |
+
|
94 |
+
$$S = \{s_1, s_2, \ldots, s_n\}$$
|
95 |
+
|
96 |
+
represent _the set of silence durations (in seconds)_ between consecutive speech segments.
|
97 |
+
|
98 |
+
- **A user-defined factor**:
|
99 |
+
|
100 |
+
$$\text{factor} \in \mathbb{R}^{+}$$
|
101 |
+
|
102 |
+
To determine a threshold that distinguishes _significant_ silence from trivial gaps, two statistical methods can be
|
103 |
+
applied:
|
104 |
+
|
105 |
+
**1. Standard Deviation-Based Threshold**
|
106 |
+
|
107 |
+
- _Mean_:
|
108 |
+
|
109 |
+
$$\mu = \frac{1}{n}\sum_{i=1}^{n}s_i$$
|
110 |
+
|
111 |
+
- _Standard Deviation_:
|
112 |
+
|
113 |
+
$$
|
114 |
+
\sigma = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(s_i - \mu)^2}
|
115 |
+
$$
|
116 |
+
|
117 |
+
- _Threshold_:
|
118 |
+
|
119 |
+
$$
|
120 |
+
T_{\text{std}} = \sigma \cdot \text{factor}
|
121 |
+
$$
|
122 |
+
|
123 |
+
**2. Median + Interquartile Range (IQR) Threshold**
|
124 |
+
|
125 |
+
- _Median_:
|
126 |
+
|
127 |
+
_Let:_
|
128 |
+
|
129 |
+
$$ S = \{s_{(1)} \leq s_{(2)} \leq \cdots \leq s_{(n)}\} $$
|
130 |
+
|
131 |
+
be an ordered set.
|
132 |
+
|
133 |
+
_Then:_
|
134 |
+
|
135 |
+
$$
|
136 |
+
M = \text{median}(S) =
|
137 |
+
\begin{cases}
|
138 |
+
s_{\frac{n+1}{2}}, & \text{if } n \text{ is odd}, \\\\[6pt]
|
139 |
+
\frac{s_{\frac{n}{2}} + s_{\frac{n}{2}+1}}{2}, & \text{if } n \text{ is even}.
|
140 |
+
\end{cases}
|
141 |
+
$$
|
142 |
+
|
143 |
+
- _Quartiles:_
|
144 |
+
|
145 |
+
$$
|
146 |
+
Q_1 = s_{(\lfloor 0.25n \rfloor)}, \quad Q_3 = s_{(\lfloor 0.75n \rfloor)}
|
147 |
+
$$
|
148 |
+
|
149 |
+
- _IQR_:
|
150 |
+
|
151 |
+
$$
|
152 |
+
\text{IQR} = Q_3 - Q_1
|
153 |
+
$$
|
154 |
+
|
155 |
+
- **Threshold:**
|
156 |
+
|
157 |
+
$$
|
158 |
+
T_{\text{median\\_iqr}} = M + (\text{IQR} \times \text{factor})
|
159 |
+
$$
|
160 |
+
|
161 |
+
**Total Silence Above Threshold**
|
162 |
+
|
163 |
+
Once the threshold
|
164 |
+
|
165 |
+
$$T$$
|
166 |
+
|
167 |
+
either
|
168 |
+
|
169 |
+
$$T_{\text{std}}$$
|
170 |
+
|
171 |
+
or
|
172 |
+
|
173 |
+
$$T_{\text{median\\_iqr}}$$
|
174 |
+
|
175 |
+
is defined, we sum only those silence durations that meet or exceed this threshold:
|
176 |
+
|
177 |
+
$$
|
178 |
+
\text{TotalSilence} = \sum_{i=1}^{n} s_i \cdot \mathbf{1}(s_i \geq T)
|
179 |
+
$$
|
180 |
+
|
181 |
+
where $$\mathbf{1}(s_i \geq T)$$ is an indicator function defined as:
|
182 |
+
|
183 |
+
$$
|
184 |
+
\mathbf{1}(s_i \geq T) =
|
185 |
+
\begin{cases}
|
186 |
+
1 & \text{if } s_i \geq T \\
|
187 |
+
0 & \text{otherwise}
|
188 |
+
\end{cases}
|
189 |
+
$$
|
190 |
+
|
191 |
+
**Summary:**
|
192 |
+
|
193 |
+
- **Identify the silence durations:**
|
194 |
+
|
195 |
+
$$
|
196 |
+
S = \{s_1, s_2, \ldots, s_n\}
|
197 |
+
$$
|
198 |
+
|
199 |
+
- **Determine the threshold using either:**
|
200 |
+
|
201 |
+
_Standard deviation-based:_
|
202 |
+
|
203 |
+
$$
|
204 |
+
T = \sigma \cdot \text{factor}
|
205 |
+
$$
|
206 |
+
|
207 |
+
_Median+IQR-based:_
|
208 |
+
|
209 |
+
$$
|
210 |
+
T = M + (\text{IQR} \cdot \text{factor})
|
211 |
+
$$
|
212 |
+
|
213 |
+
- **Compute the total silence above this threshold:**
|
214 |
+
|
215 |
+
$$
|
216 |
+
\text{TotalSilence} = \sum_{i=1}^{n} s_i \cdot \mathbf{1}(s_i \geq T)
|
217 |
+
$$
|
218 |
+
|
219 |
+
---
|
220 |
+
|
221 |
+
### Features
|
222 |
+
|
223 |
+
- [x] Speech Enhancement
|
224 |
+
- [x] Sentiment Analysis
|
225 |
+
- [x] Profanity Word Detection
|
226 |
+
- [x] Summary
|
227 |
+
- [x] Conflict Detection
|
228 |
+
- [x] Topic Detection
|
229 |
+
|
230 |
+
---
|
231 |
+
|
232 |
+
### Demo
|
233 |
+
|
234 |
+

|
235 |
+
|
236 |
+
---
|
237 |
+
|
238 |
+
### Installation
|
239 |
+
|
240 |
+
##### Linux/Ubuntu
|
241 |
+
|
242 |
+
```bash
|
243 |
+
sudo apt update -y && sudo apt upgrade -y
|
244 |
+
```
|
245 |
+
|
246 |
+
```bash
|
247 |
+
sudo apt install ffmpeg -y
|
248 |
+
```
|
249 |
+
|
250 |
+
```bash
|
251 |
+
sudo apt install -y ffmpeg build-essential g++
|
252 |
+
```
|
253 |
+
|
254 |
+
```bash
|
255 |
+
git clone https://github.com/bunyaminergen/Callytics
|
256 |
+
```
|
257 |
+
|
258 |
+
```bash
|
259 |
+
cd Callytics
|
260 |
+
```
|
261 |
+
|
262 |
+
```bash
|
263 |
+
conda env create -f environment.yaml
|
264 |
+
```
|
265 |
+
|
266 |
+
```bash
|
267 |
+
conda activate Callytics
|
268 |
+
```
|
269 |
+
|
270 |
+
##### Environment
|
271 |
+
|
272 |
+
`.env` file sample:
|
273 |
+
|
274 |
+
```Text
|
275 |
+
# CREDENTIALS
|
276 |
+
# OPENAI
|
277 |
+
OPENAI_API_KEY=
|
278 |
+
|
279 |
+
# HUGGINGFACE
|
280 |
+
HUGGINGFACE_TOKEN=
|
281 |
+
|
282 |
+
# AZURE OPENAI
|
283 |
+
AZURE_OPENAI_API_KEY=
|
284 |
+
AZURE_OPENAI_API_BASE=
|
285 |
+
AZURE_OPENAI_API_VERSION=
|
286 |
+
|
287 |
+
# DATABASE
|
288 |
+
DB_NAME=
|
289 |
+
DB_USER=
|
290 |
+
DB_PASSWORD=
|
291 |
+
DB_HOST=
|
292 |
+
DB_PORT=
|
293 |
+
DB_URL=
|
294 |
+
```
|
295 |
+
|
296 |
+
---
|
297 |
+
|
298 |
+
##### Database
|
299 |
+
|
300 |
+
_In this section, an `example database` and `tables` are provided. It is a `well-structured` and `simple design`. If you
|
301 |
+
create the tables
|
302 |
+
and columns in the same structure in your remote database, you will not encounter errors in the code. However, if you
|
303 |
+
want to change the database structure, you will also need to refactor the code._
|
304 |
+
|
305 |
+
*Note*: __Refer to the [Database Structure](#database-structure) section for the database schema and tables.__
|
306 |
+
|
307 |
+
```bash
|
308 |
+
sqlite3 .db/Callytics.sqlite < src/db/sql/Schema.sql
|
309 |
+
```
|
310 |
+
|
311 |
+
##### Grafana
|
312 |
+
|
313 |
+
_In this section, it is explained how to install `Grafana` on your `local` environment. Since Grafana is a third-party
|
314 |
+
open-source monitoring application, you must handle its installation yourself and connect your database. Of course, you
|
315 |
+
can also use it with `Granafa Cloud` instead of `local` environment._
|
316 |
+
|
317 |
+
```bash
|
318 |
+
sudo apt update -y && sudo apt upgrade -y
|
319 |
+
```
|
320 |
+
|
321 |
+
```bash
|
322 |
+
sudo apt install -y apt-transport-https software-properties-common wget
|
323 |
+
```
|
324 |
+
|
325 |
+
```bash
|
326 |
+
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
|
327 |
+
```
|
328 |
+
|
329 |
+
```bash
|
330 |
+
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
|
331 |
+
```
|
332 |
+
|
333 |
+
```bash
|
334 |
+
sudo apt install -y grafana
|
335 |
+
```
|
336 |
+
|
337 |
+
```bash
|
338 |
+
sudo systemctl start grafana-server
|
339 |
+
sudo systemctl enable grafana-server
|
340 |
+
sudo systemctl daemon-reload
|
341 |
+
```
|
342 |
+
|
343 |
+
```bash
|
344 |
+
http://localhost:3000
|
345 |
+
```
|
346 |
+
|
347 |
+
**SQLite Plugin**
|
348 |
+
|
349 |
+
```bash
|
350 |
+
sudo grafana-cli plugins install frser-sqlite-datasource
|
351 |
+
```
|
352 |
+
|
353 |
+
```bash
|
354 |
+
sudo systemctl restart grafana-server
|
355 |
+
```
|
356 |
+
|
357 |
+
```bash
|
358 |
+
sudo systemctl daemon-reload
|
359 |
+
```
|
360 |
+
|
361 |
+
### File Structure
|
362 |
+
|
363 |
+
```Text
|
364 |
+
.
|
365 |
+
├── automation
|
366 |
+
│ └── service
|
367 |
+
│ └── callytics.service
|
368 |
+
├── config
|
369 |
+
│ ├── config.yaml
|
370 |
+
│ ├── nemo
|
371 |
+
│ │ └── diar_infer_telephonic.yaml
|
372 |
+
│ └── prompt.yaml
|
373 |
+
├── .data
|
374 |
+
│ ├── example
|
375 |
+
│ │ └── LogisticsCallCenterConversation.mp3
|
376 |
+
│ └── input
|
377 |
+
├── .db
|
378 |
+
│ └── Callytics.sqlite
|
379 |
+
├── .docs
|
380 |
+
│ ├── documentation
|
381 |
+
│ │ ├── CONTRIBUTING.md
|
382 |
+
│ │ └── RESOURCES.md
|
383 |
+
│ └── img
|
384 |
+
│ ├── Callytics.drawio
|
385 |
+
│ ├── Callytics.gif
|
386 |
+
│ ├── CallyticsIcon.png
|
387 |
+
│ ├── Callytics.png
|
388 |
+
│ ├── Callytics.svg
|
389 |
+
│ └── database.png
|
390 |
+
├── .env
|
391 |
+
├── environment.yaml
|
392 |
+
├── .gitattributes
|
393 |
+
├── .github
|
394 |
+
│ └── CODEOWNERS
|
395 |
+
├── .gitignore
|
396 |
+
├── LICENSE
|
397 |
+
├── main.py
|
398 |
+
├── README.md
|
399 |
+
├── requirements.txt
|
400 |
+
└── src
|
401 |
+
├── audio
|
402 |
+
│ ├── alignment.py
|
403 |
+
│ ├── analysis.py
|
404 |
+
│ ├── effect.py
|
405 |
+
│ ├── error.py
|
406 |
+
│ ├── io.py
|
407 |
+
│ ├── metrics.py
|
408 |
+
│ ├── preprocessing.py
|
409 |
+
│ ├── processing.py
|
410 |
+
│ └── utils.py
|
411 |
+
├── db
|
412 |
+
│ ├── manager.py
|
413 |
+
│ └── sql
|
414 |
+
│ ├── AudioPropertiesInsert.sql
|
415 |
+
│ ├── Schema.sql
|
416 |
+
│ ├── TopicFetch.sql
|
417 |
+
│ ├── TopicInsert.sql
|
418 |
+
│ └── UtteranceInsert.sql
|
419 |
+
├── text
|
420 |
+
│ ├── llm.py
|
421 |
+
│ ├── model.py
|
422 |
+
│ ├── prompt.py
|
423 |
+
│ └── utils.py
|
424 |
+
└── utils
|
425 |
+
└── utils.py
|
426 |
+
|
427 |
+
19 directories, 43 files
|
428 |
+
```
|
429 |
+
|
430 |
+
---
|
431 |
+
|
432 |
+
### Database Structure
|
433 |
+
|
434 |
+

|
435 |
+
|
436 |
+
|
437 |
+
---
|
438 |
+
|
439 |
+
### Datasets
|
440 |
+
|
441 |
+
- [Callytics Speaker Verification Dataset *(CSVD)*](.data/groundtruth/speakerverification/DatasetCard.md)
|
442 |
+
|
443 |
+
---
|
444 |
+
|
445 |
+
### Version Control System
|
446 |
+
|
447 |
+
##### Releases
|
448 |
+
|
449 |
+
- [v1.0.0](https://github.com/bunyaminergen/Callytics/archive/refs/tags/v1.0.0.zip) _.zip_
|
450 |
+
- [v1.0.0](https://github.com/bunyaminergen/Callytics/archive/refs/tags/v1.0.0.tar.gz) _.tar.gz_
|
451 |
+
|
452 |
+
|
453 |
+
- [v1.1.0](https://github.com/bunyaminergen/Callytics/archive/refs/tags/v1.1.0.zip) _.zip_
|
454 |
+
- [v1.1.0](https://github.com/bunyaminergen/Callytics/archive/refs/tags/v1.1.0.tar.gz) _.tar.gz_
|
455 |
+
|
456 |
+
##### Branches
|
457 |
+
|
458 |
+
- [main](https://github.com/bunyaminergen/Callytics/tree/main)
|
459 |
+
- [develop](https://github.com/bunyaminergen/Callytics/tree/develop)
|
460 |
+
|
461 |
---
|
462 |
+
|
463 |
+
### Upcoming
|
464 |
+
|
465 |
+
- [ ] **Speech Emotion Recognition:** Develop a model to automatically detect emotions from speech data.
|
466 |
+
- [ ] **New Forced Alignment Model:** Train a forced alignment model from scratch.
|
467 |
+
- [ ] **New Vocal Separation Model:** Train a vocal separation model from scratch.
|
468 |
+
- [ ] **Unit Tests:** Add a comprehensive unit testing script to validate functionality.
|
469 |
+
- [ ] **Logging Logic:** Implement a more comprehensive and structured logging mechanism.
|
470 |
+
- [ ] **Warnings:** Add meaningful and detailed warning messages for better user guidance.
|
471 |
+
- [ ] **Real-Time Analysis:** Enable real-time analysis capabilities within the system.
|
472 |
+
- [ ] **Dockerization:** Containerize the repository to ensure seamless deployment and environment consistency.
|
473 |
+
- [ ] **New Transcription Models:** Integrate and test new transcription models
|
474 |
+
suchas [AIOLA’s Multi-Head Speech Recognition Model](https://venturebeat.com/ai/aiola-drops-ultra-fast-multi-head-speech-recognition-model-beats-openai-whisper/).
|
475 |
+
- [ ] **Noise Reduction Model:** Identify, test, and integrate a deep learning-based noise reduction model. Consider
|
476 |
+
existing models like **Facebook Research Denoiser**, **Noise2Noise**, **Audio Denoiser CNN**. Write test scripts for
|
477 |
+
evaluation, and if necessary, train a new model for optimal performance.
|
478 |
+
|
479 |
+
##### Considerations
|
480 |
+
|
481 |
+
- [ ] Detect CSR's identity via Voice Recognition/Identification instead of Diarization and LLM.
|
482 |
+
- [ ] Transform the code structure into a pipeline for better modularity and scalability.
|
483 |
+
- [ ] Publish the repository as a Python package on **PyPI** for wider distribution.
|
484 |
+
- [ ] Convert the repository into a Linux package to support Linux-based systems.
|
485 |
+
- [ ] Implement a two-step processing workflow: perform **diarization** (speaker segmentation) first, then apply *
|
486 |
+
*transcription** for each identified speaker separately. This approach can improve transcription accuracy by
|
487 |
+
leveraging speaker separation.
|
488 |
+
- [ ] Enable **parallel processing** for tasks such as diarization, transcription, and model inference to improve
|
489 |
+
overall system performance and reduce processing time.
|
490 |
+
- [ ] Explore using **Docker Compose** for multi-container orchestration if required.
|
491 |
+
- [ ] Upload the models and relevant resources to **Hugging Face** for easier access, sharing, and community
|
492 |
+
collaboration.
|
493 |
+
- [ ] Consider writing a **Command Line Interface (CLI)** to simplify user interaction and improve usability.
|
494 |
+
- [ ] Test the ability to use **different language models (LLMs)** for specific tasks. For instance, using **BERT** for
|
495 |
+
profanity detection. Evaluate their performance and suitability for different use cases as a feature.
|
496 |
+
|
497 |
---
|
498 |
|
499 |
+
### Documentations
|
500 |
+
|
501 |
+
- [RESOURCES](.docs/documentation/RESOURCES.md)
|
502 |
+
- [CONTRIBUTING](.docs/documentation/CONTRIBUTING.md)
|
503 |
+
- [PRESENTATION](.docs/presentation/CallyticsPresentationEN.pdf)
|
504 |
+
|
505 |
+
---
|
506 |
+
|
507 |
+
### Licence
|
508 |
+
|
509 |
+
- [LICENSE](LICENSE)
|
510 |
+
|
511 |
+
---
|
512 |
+
|
513 |
+
### Links
|
514 |
+
|
515 |
+
- [Github](https://github.com/bunyaminergen/Callytics)
|
516 |
+
- [Website](https://bunyaminergen.com)
|
517 |
+
- [Linkedin](https://www.linkedin.com/in/bunyaminergen)
|
518 |
+
|
519 |
+
---
|
520 |
+
|
521 |
+
### Team
|
522 |
+
|
523 |
+
- [Bunyamin Ergen](https://www.linkedin.com/in/bunyaminergen)
|
524 |
+
|
525 |
+
---
|
526 |
+
|
527 |
+
### Contact
|
528 |
+
|
529 |
+
- [Mail](mailto:[email protected])
|
530 |
+
|
531 |
+
---
|
532 |
+
|
533 |
+
### Citation
|
534 |
+
|
535 |
+
```bibtex
|
536 |
+
@software{ Callytics,
|
537 |
+
author = {Bunyamin Ergen},
|
538 |
+
title = {{Callytics}},
|
539 |
+
year = {2024},
|
540 |
+
month = {12},
|
541 |
+
url = {https://github.com/bunyaminergen/Callytics},
|
542 |
+
version = {v1.1.0},
|
543 |
+
}
|
544 |
+
```
|
545 |
+
|
546 |
+
---
|
automation/service/callytics.service
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[Unit]
|
2 |
+
Description=Callytics
|
3 |
+
After=network.target
|
4 |
+
|
5 |
+
[Service]
|
6 |
+
Type=simple
|
7 |
+
User=bunyamin
|
8 |
+
EnvironmentFile=/home/bunyamin/Callytics/.env
|
9 |
+
WorkingDirectory=/home/bunyamin/Callytics
|
10 |
+
ExecStart=/bin/bash -c "source /home/bunyamin/anaconda3/etc/profile.d/conda.sh \
|
11 |
+
&& conda activate Callytics \
|
12 |
+
&& python /home/bunyamin/Callytics/main.py"
|
13 |
+
Restart=on-failure
|
14 |
+
RestartSec=5
|
15 |
+
StandardOutput=journal
|
16 |
+
StandardError=journal
|
17 |
+
|
18 |
+
[Install]
|
19 |
+
WantedBy=multi-user.target
|
config/config.yaml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
runtime:
|
2 |
+
device: "cpu" # Options: "cpu", "cuda"
|
3 |
+
compute_type: "int8" # Options: "int8", "float16"
|
4 |
+
cuda_alloc_conf: "expandable_segments:True" # PyTorch CUDA Memory Management
|
5 |
+
|
6 |
+
language:
|
7 |
+
audio: "en" # Options: "en", "tr"
|
8 |
+
text: "en" # Options: "en", "tr"
|
9 |
+
|
10 |
+
models:
|
11 |
+
llama:
|
12 |
+
model_name: "meta-llama/Llama-3.2-3B-Instruct" # Options: "meta-llama/Llama-3.2-3B-Instruct", etc.
|
13 |
+
huggingface_api_key: "${HUGGINGFACE_TOKEN}"
|
14 |
+
|
15 |
+
openai:
|
16 |
+
model_name: "gpt-4o" # Options: "gpt-4", "gpt-4o", etc.
|
17 |
+
openai_api_key: "${OPENAI_API_KEY}"
|
18 |
+
|
19 |
+
azure_openai:
|
20 |
+
model_name: "gpt-4o" # Options: "gpt-4", "gpt-4o", etc.
|
21 |
+
azure_openai_api_key: "${AZURE_OPENAI_API_KEY}"
|
22 |
+
azure_openai_api_base: "${AZURE_OPENAI_API_BASE}"
|
23 |
+
azure_openai_api_version: "${AZURE_OPENAI_API_VERSION}"
|
24 |
+
|
25 |
+
mpsenet:
|
26 |
+
model_name: "JacobLinCool/MP-SENet-DNS" # Options: "JacobLinCool/MP-SENet-DNS", "JacobLinCool/MP-SENet-VB"
|
config/nemo/diar_infer_telephonic.yaml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "ClusterDiarizer"
|
2 |
+
|
3 |
+
num_workers: 1
|
4 |
+
sample_rate: 16000
|
5 |
+
batch_size: 64
|
6 |
+
device: cuda
|
7 |
+
verbose: True
|
8 |
+
|
9 |
+
diarizer:
|
10 |
+
manifest_filepath: .temp/manifest.json
|
11 |
+
out_dir: .temp
|
12 |
+
oracle_vad: False
|
13 |
+
collar: 0.25
|
14 |
+
ignore_overlap: True
|
15 |
+
|
16 |
+
vad:
|
17 |
+
model_path: vad_multilingual_marblenet
|
18 |
+
external_vad_manifest: null
|
19 |
+
parameters:
|
20 |
+
window_length_in_sec: 0.15
|
21 |
+
shift_length_in_sec: 0.01
|
22 |
+
smoothing: "median"
|
23 |
+
overlap: 0.5
|
24 |
+
onset: 0.1
|
25 |
+
offset: 0.1
|
26 |
+
pad_onset: 0.1
|
27 |
+
pad_offset: 0
|
28 |
+
min_duration_on: 0
|
29 |
+
min_duration_off: 0.2
|
30 |
+
filter_speech_first: True
|
31 |
+
|
32 |
+
speaker_embeddings:
|
33 |
+
model_path: titanet_large
|
34 |
+
parameters:
|
35 |
+
window_length_in_sec: [ 1.5,1.25,1.0,0.75,0.5 ]
|
36 |
+
shift_length_in_sec: [ 0.75,0.625,0.5,0.375,0.25 ]
|
37 |
+
multiscale_weights: [ 1,1,1,1,1 ]
|
38 |
+
save_embeddings: True
|
39 |
+
|
40 |
+
clustering:
|
41 |
+
parameters:
|
42 |
+
oracle_num_speakers: False
|
43 |
+
max_num_speakers: 8
|
44 |
+
enhanced_count_thres: 80
|
45 |
+
max_rp_threshold: 0.25
|
46 |
+
sparse_search_volume: 30
|
47 |
+
maj_vote_spk_count: False
|
48 |
+
chunk_cluster_count: 50
|
49 |
+
embeddings_per_chunk: 10000
|
50 |
+
|
51 |
+
msdd_model:
|
52 |
+
model_path: diar_msdd_telephonic
|
53 |
+
parameters:
|
54 |
+
use_speaker_model_from_ckpt: True
|
55 |
+
infer_batch_size: 25
|
56 |
+
sigmoid_threshold: [ 0.7 ]
|
57 |
+
seq_eval_mode: False
|
58 |
+
split_infer: True
|
59 |
+
diar_window_length: 50
|
60 |
+
overlap_infer_spk_limit: 5
|
61 |
+
|
62 |
+
asr:
|
63 |
+
model_path: stt_en_conformer_ctc_large
|
64 |
+
parameters:
|
65 |
+
asr_based_vad: False
|
66 |
+
asr_based_vad_threshold: 1.0
|
67 |
+
asr_batch_size: null
|
68 |
+
decoder_delay_in_sec: null
|
69 |
+
word_ts_anchor_offset: null
|
70 |
+
word_ts_anchor_pos: "start"
|
71 |
+
fix_word_ts_with_VAD: False
|
72 |
+
colored_text: False
|
73 |
+
print_time: True
|
74 |
+
break_lines: False
|
75 |
+
|
76 |
+
ctc_decoder_parameters:
|
77 |
+
pretrained_language_model: null
|
78 |
+
beam_width: 32
|
79 |
+
alpha: 0.5
|
80 |
+
beta: 2.5
|
81 |
+
|
82 |
+
realigning_lm_parameters:
|
83 |
+
arpa_language_model: null
|
84 |
+
min_number_of_words: 3
|
85 |
+
max_number_of_words: 10
|
86 |
+
logprob_diff_threshold: 1.2
|
config/prompt.yaml
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Classification:
|
2 |
+
system: >
|
3 |
+
Your task is to identify the role of each speaker as either 'Customer' or 'Customer Service Representative (CSR)'.
|
4 |
+
In the resulting JSON object, use the keys 'Customer' for the Customer and 'CSR' for the Customer Service
|
5 |
+
Representative. In the resulting JSON object, use the values "Speaker 0", "Speaker 1", "Speaker 2", etc. Please
|
6 |
+
respond with a valid JSON object. Ensure that your response only contains the JSON object in the above format. Do
|
7 |
+
not include any explanatory text, additional comments, or formatting. Now, analyze the following conversation:
|
8 |
+
|
9 |
+
user: >
|
10 |
+
{user_context}
|
11 |
+
|
12 |
+
|
13 |
+
SentimentAnalysis:
|
14 |
+
system: >
|
15 |
+
You are a sentiment analysis tool. For each sentence in the provided input, identify its sentiment as "Positive",
|
16 |
+
"Negative", or "Neutral". The index in your output should match the order of the sentences in the input, starting
|
17 |
+
from the same position as shown in the input data (e.g., index always start from 0). Respond **only** with
|
18 |
+
a valid JSON object in the exact format specified below. Do not include any additional text. The JSON should have a
|
19 |
+
"sentiments" key containing a list of objects, where each object has "index" (matching the input sentence's index)
|
20 |
+
and "sentiment" keys.
|
21 |
+
|
22 |
+
Example:
|
23 |
+
{{
|
24 |
+
"sentiments": [
|
25 |
+
{{"index": 0, "sentiment": "Positive"}},
|
26 |
+
{{"index": 1, "sentiment": "Neutral"}},
|
27 |
+
{{"index": 2, "sentiment": "Negative"}}
|
28 |
+
]
|
29 |
+
}}
|
30 |
+
|
31 |
+
Analyze the following conversation and ensure the indices match the input:
|
32 |
+
user: >
|
33 |
+
{user_context}
|
34 |
+
|
35 |
+
|
36 |
+
ProfanityWordDetection:
|
37 |
+
system: >
|
38 |
+
You are a profanity word detection tool. For each sentence in the provided input, identify if it contains any
|
39 |
+
profane words. The index in your output should match the order of the sentences in the input, starting from the
|
40 |
+
same position as shown in the input data (e.g., index always start from 0). Respond **only** with a valid JSON
|
41 |
+
object in the exact format specified below. Do not include any additional text. The JSON should have a "profanity"
|
42 |
+
key containing a list of objects, where each object has "index" (matching the input sentence's index) and
|
43 |
+
"profane" (a boolean value) keys.
|
44 |
+
|
45 |
+
Example:
|
46 |
+
{{
|
47 |
+
"profanity": [
|
48 |
+
{{"index": 0, "profane": "true"}},
|
49 |
+
{{"index": 1, "profane": "false"}},
|
50 |
+
{{"index": 2, "profane": "true"}}
|
51 |
+
]
|
52 |
+
}}
|
53 |
+
|
54 |
+
Analyze the following conversation and ensure the indices match the input:
|
55 |
+
user: >
|
56 |
+
{user_context}
|
57 |
+
|
58 |
+
Summary:
|
59 |
+
system: >
|
60 |
+
Your task is to summarize the entire conversation in a single sentence. The summary should capture the essence
|
61 |
+
of the interaction, including the main purpose and any key outcomes. Respond **only** with a valid JSON object
|
62 |
+
in the exact format specified below. Do not include any additional text. The JSON should have a single key
|
63 |
+
"summary" with a string value.
|
64 |
+
|
65 |
+
Example:
|
66 |
+
{
|
67 |
+
"summary": "The customer requested a copy of their invoice and the CSR confirmed it would be sent by email."
|
68 |
+
}
|
69 |
+
|
70 |
+
Now, summarize the following conversation:
|
71 |
+
user: >
|
72 |
+
{user_context}
|
73 |
+
|
74 |
+
ConflictDetection:
|
75 |
+
system: >
|
76 |
+
Your task is to determine if there is any conflict or disagreement between the speakers in the given conversation.
|
77 |
+
A conflict is defined as any instance where the speakers express opposing views, argue, or express frustration.
|
78 |
+
Respond **only** with a valid JSON object in the exact format specified below. Do not include any additional text.
|
79 |
+
The JSON should have a single key "conflict" with a boolean value.
|
80 |
+
|
81 |
+
Example:
|
82 |
+
{
|
83 |
+
"conflict": true
|
84 |
+
}
|
85 |
+
|
86 |
+
Now, analyze the following conversation:
|
87 |
+
user: >
|
88 |
+
{user_context}
|
89 |
+
|
90 |
+
TopicDetection:
|
91 |
+
system: >
|
92 |
+
Your task is to identify the topic of a conversation. You will receive a conversation transcript and a
|
93 |
+
list of predefined topics. Your job is to determine which topic best matches the conversation. If none
|
94 |
+
of the provided topics match, suggest a new topic based on the conversation content.
|
95 |
+
|
96 |
+
Here is the list of predefined topics: {system_context}.
|
97 |
+
|
98 |
+
Respond **only** with a valid JSON object in the exact format specified below. Do not include any additional text.
|
99 |
+
The JSON should have one key: "topic" (a string that is the matched topic or new topic).
|
100 |
+
|
101 |
+
Example:
|
102 |
+
{{
|
103 |
+
"topic": "Billing"
|
104 |
+
}}
|
105 |
+
|
106 |
+
user: >
|
107 |
+
{user_context}
|
environment.yaml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Callytics
|
2 |
+
channels:
|
3 |
+
- defaults
|
4 |
+
- conda-forge
|
5 |
+
dependencies:
|
6 |
+
- python=3.11
|
7 |
+
- pip:
|
8 |
+
- cython==3.0.11
|
9 |
+
- nemo_toolkit[asr]>=2.dev
|
10 |
+
- nltk==3.9.1
|
11 |
+
- faster-whisper==1.1.0
|
12 |
+
- demucs==4.0.1
|
13 |
+
- deepmultilingualpunctuation @ git+https://github.com/oliverguhr/deepmultilingualpunctuation.git@5a0dd7f4fd56687f59405aa8eba1144393d8b74b
|
14 |
+
- ctc-forced-aligner @ git+https://github.com/MahmoudAshraf97/ctc-forced-aligner.git@c7cc7ce609e5f8f1f553fbd1e53124447ffe46d8
|
15 |
+
- openai==1.57.0
|
16 |
+
- accelerate>=0.26.0
|
17 |
+
- torch==2.5.1
|
18 |
+
- pydub==0.25.1
|
19 |
+
- omegaconf==2.3.0
|
20 |
+
- python-dotenv==1.0.1
|
21 |
+
- transformers==4.47.0
|
22 |
+
- librosa==0.10.2.post1
|
23 |
+
- soundfile==0.12.1
|
24 |
+
- noisereduce==3.0.3
|
25 |
+
- numpy==1.26.4
|
26 |
+
- pyannote.audio==3.3.2
|
27 |
+
- watchdog==6.0.0
|
28 |
+
- scipy==1.14.1
|
29 |
+
- IPython==8.30.0
|
30 |
+
- pyyaml==6.0.2
|
31 |
+
- MPSENet==1.0.3
|
main.py
ADDED
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
|
4 |
+
# Related third-party imports
|
5 |
+
from omegaconf import OmegaConf
|
6 |
+
from nemo.collections.asr.models.msdd_models import NeuralDiarizer
|
7 |
+
|
8 |
+
# Local imports
|
9 |
+
from src.audio.utils import Formatter
|
10 |
+
from src.audio.metrics import SilenceStats
|
11 |
+
from src.audio.error import DialogueDetecting
|
12 |
+
from src.audio.alignment import ForcedAligner
|
13 |
+
from src.audio.effect import DemucsVocalSeparator
|
14 |
+
from src.audio.preprocessing import SpeechEnhancement
|
15 |
+
from src.audio.io import SpeakerTimestampReader, TranscriptWriter
|
16 |
+
from src.audio.analysis import WordSpeakerMapper, SentenceSpeakerMapper, Audio
|
17 |
+
from src.audio.processing import AudioProcessor, Transcriber, PunctuationRestorer
|
18 |
+
from src.text.utils import Annotator
|
19 |
+
from src.text.llm import LLMOrchestrator, LLMResultHandler
|
20 |
+
from src.utils.utils import Cleaner, Watcher
|
21 |
+
from src.db.manager import Database
|
22 |
+
|
23 |
+
|
24 |
+
async def main(audio_file_path: str):
|
25 |
+
"""
|
26 |
+
Process an audio file to perform diarization, transcription, punctuation restoration,
|
27 |
+
and speaker role classification.
|
28 |
+
|
29 |
+
Parameters
|
30 |
+
----------
|
31 |
+
audio_file_path : str
|
32 |
+
The path to the input audio file to be processed.
|
33 |
+
|
34 |
+
Returns
|
35 |
+
-------
|
36 |
+
None
|
37 |
+
"""
|
38 |
+
# Paths
|
39 |
+
config_nemo = "config/nemo/diar_infer_telephonic.yaml"
|
40 |
+
manifest_path = ".temp/manifest.json"
|
41 |
+
temp_dir = ".temp"
|
42 |
+
rttm_file_path = os.path.join(temp_dir, "pred_rttms", "mono_file.rttm")
|
43 |
+
transcript_output_path = ".temp/output.txt"
|
44 |
+
srt_output_path = ".temp/output.srt"
|
45 |
+
config_path = "config/config.yaml"
|
46 |
+
prompt_path = "config/prompt.yaml"
|
47 |
+
db_path = ".db/Callytics.sqlite"
|
48 |
+
db_topic_fetch_path = "src/db/sql/TopicFetch.sql"
|
49 |
+
db_topic_insert_path = "src/db/sql/TopicInsert.sql"
|
50 |
+
db_audio_properties_insert_path = "src/db/sql/AudioPropertiesInsert.sql"
|
51 |
+
db_utterance_insert_path = "src/db/sql/UtteranceInsert.sql"
|
52 |
+
|
53 |
+
# Configuration
|
54 |
+
config = OmegaConf.load(config_path)
|
55 |
+
device = config.runtime.device
|
56 |
+
compute_type = config.runtime.compute_type
|
57 |
+
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = config.runtime.cuda_alloc_conf
|
58 |
+
|
59 |
+
# Initialize Classes
|
60 |
+
dialogue_detector = DialogueDetecting(delete_original=True)
|
61 |
+
enhancer = SpeechEnhancement(config_path=config_path, output_dir=temp_dir)
|
62 |
+
separator = DemucsVocalSeparator()
|
63 |
+
processor = AudioProcessor(audio_path=audio_file_path, temp_dir=temp_dir)
|
64 |
+
transcriber = Transcriber(device=device, compute_type=compute_type)
|
65 |
+
aligner = ForcedAligner(device=device)
|
66 |
+
llm_handler = LLMOrchestrator(config_path=config_path, prompt_config_path=prompt_path, model_id="openai")
|
67 |
+
llm_result_handler = LLMResultHandler()
|
68 |
+
cleaner = Cleaner()
|
69 |
+
formatter = Formatter()
|
70 |
+
db = Database(db_path)
|
71 |
+
audio_feature_extractor = Audio(audio_file_path)
|
72 |
+
|
73 |
+
# Step 1: Detect Dialogue
|
74 |
+
has_dialogue = dialogue_detector.process(audio_file_path)
|
75 |
+
if not has_dialogue:
|
76 |
+
return
|
77 |
+
|
78 |
+
# Step 2: Speech Enhancement
|
79 |
+
audio_path = enhancer.enhance_audio(
|
80 |
+
input_path=audio_file_path,
|
81 |
+
output_path=os.path.join(temp_dir, "enhanced.wav"),
|
82 |
+
noise_threshold=0.0001,
|
83 |
+
verbose=True
|
84 |
+
)
|
85 |
+
|
86 |
+
# Step 3: Vocal Separation
|
87 |
+
vocal_path = separator.separate_vocals(audio_file=audio_path, output_dir=temp_dir)
|
88 |
+
|
89 |
+
# Step 4: Transcription
|
90 |
+
transcript, info = transcriber.transcribe(audio_path=vocal_path)
|
91 |
+
detected_language = info["language"]
|
92 |
+
|
93 |
+
# Step 5: Forced Alignment
|
94 |
+
word_timestamps = aligner.align(
|
95 |
+
audio_path=vocal_path,
|
96 |
+
transcript=transcript,
|
97 |
+
language=detected_language
|
98 |
+
)
|
99 |
+
|
100 |
+
# Step 6: Diarization
|
101 |
+
processor.audio_path = vocal_path
|
102 |
+
mono_audio_path = processor.convert_to_mono()
|
103 |
+
processor.audio_path = mono_audio_path
|
104 |
+
processor.create_manifest(manifest_path)
|
105 |
+
cfg = OmegaConf.load(config_nemo)
|
106 |
+
cfg.diarizer.manifest_filepath = manifest_path
|
107 |
+
cfg.diarizer.out_dir = temp_dir
|
108 |
+
msdd_model = NeuralDiarizer(cfg=cfg)
|
109 |
+
msdd_model.diarize()
|
110 |
+
|
111 |
+
# Step 7: Processing Transcript
|
112 |
+
# Step 7.1: Speaker Timestamps
|
113 |
+
speaker_reader = SpeakerTimestampReader(rttm_path=rttm_file_path)
|
114 |
+
speaker_ts = speaker_reader.read_speaker_timestamps()
|
115 |
+
|
116 |
+
# Step 7.2: Mapping Words
|
117 |
+
word_speaker_mapper = WordSpeakerMapper(word_timestamps, speaker_ts)
|
118 |
+
wsm = word_speaker_mapper.get_words_speaker_mapping()
|
119 |
+
|
120 |
+
# Step 7.3: Punctuation Restoration
|
121 |
+
punct_restorer = PunctuationRestorer(language=detected_language)
|
122 |
+
wsm = punct_restorer.restore_punctuation(wsm)
|
123 |
+
word_speaker_mapper.word_speaker_mapping = wsm
|
124 |
+
word_speaker_mapper.realign_with_punctuation()
|
125 |
+
wsm = word_speaker_mapper.word_speaker_mapping
|
126 |
+
|
127 |
+
# Step 7.4: Mapping Sentences
|
128 |
+
sentence_mapper = SentenceSpeakerMapper()
|
129 |
+
ssm = sentence_mapper.get_sentences_speaker_mapping(wsm)
|
130 |
+
|
131 |
+
# Step 8 (Optional): Write Transcript and SRT Files
|
132 |
+
writer = TranscriptWriter()
|
133 |
+
writer.write_transcript(ssm, transcript_output_path)
|
134 |
+
writer.write_srt(ssm, srt_output_path)
|
135 |
+
|
136 |
+
# Step 9: Classify Speaker Roles
|
137 |
+
speaker_roles = await llm_handler.generate("Classification", ssm)
|
138 |
+
|
139 |
+
# Step 9.1: LLM results validate and fallback
|
140 |
+
ssm = llm_result_handler.validate_and_fallback(speaker_roles, ssm)
|
141 |
+
llm_result_handler.log_result(ssm, speaker_roles)
|
142 |
+
|
143 |
+
# Step 10: Sentiment Analysis
|
144 |
+
ssm_with_indices = formatter.add_indices_to_ssm(ssm)
|
145 |
+
annotator = Annotator(ssm_with_indices)
|
146 |
+
sentiment_results = await llm_handler.generate("SentimentAnalysis", user_input=ssm)
|
147 |
+
annotator.add_sentiment(sentiment_results)
|
148 |
+
|
149 |
+
# Step 11: Profanity Word Detection
|
150 |
+
profane_results = await llm_handler.generate("ProfanityWordDetection", user_input=ssm)
|
151 |
+
annotator.add_profanity(profane_results)
|
152 |
+
|
153 |
+
# Step 12: Summary
|
154 |
+
summary_result = await llm_handler.generate("Summary", user_input=ssm)
|
155 |
+
annotator.add_summary(summary_result)
|
156 |
+
|
157 |
+
# Step 13: Conflict Detection
|
158 |
+
conflict_result = await llm_handler.generate("ConflictDetection", user_input=ssm)
|
159 |
+
annotator.add_conflict(conflict_result)
|
160 |
+
|
161 |
+
# Step 14: Topic Detection
|
162 |
+
topics = db.fetch(db_topic_fetch_path)
|
163 |
+
topic_result = await llm_handler.generate(
|
164 |
+
"TopicDetection",
|
165 |
+
user_input=ssm,
|
166 |
+
system_input=topics
|
167 |
+
)
|
168 |
+
annotator.add_topic(topic_result)
|
169 |
+
|
170 |
+
# Step 15: File/Audio Feature Extraction
|
171 |
+
props = audio_feature_extractor.properties()
|
172 |
+
|
173 |
+
(
|
174 |
+
name,
|
175 |
+
file_extension,
|
176 |
+
absolute_file_path,
|
177 |
+
sample_rate,
|
178 |
+
min_frequency,
|
179 |
+
max_frequency,
|
180 |
+
audio_bit_depth,
|
181 |
+
num_channels,
|
182 |
+
audio_duration,
|
183 |
+
rms_loudness,
|
184 |
+
final_features
|
185 |
+
) = props
|
186 |
+
|
187 |
+
rms_loudness_db = final_features["RMSLoudness"]
|
188 |
+
zero_crossing_rate_db = final_features["ZeroCrossingRate"]
|
189 |
+
spectral_centroid_db = final_features["SpectralCentroid"]
|
190 |
+
eq_20_250_db = final_features["EQ_20_250_Hz"]
|
191 |
+
eq_250_2000_db = final_features["EQ_250_2000_Hz"]
|
192 |
+
eq_2000_6000_db = final_features["EQ_2000_6000_Hz"]
|
193 |
+
eq_6000_20000_db = final_features["EQ_6000_20000_Hz"]
|
194 |
+
mfcc_values = [final_features[f"MFCC_{i}"] for i in range(1, 14)]
|
195 |
+
|
196 |
+
final_output = annotator.finalize()
|
197 |
+
|
198 |
+
# Step 16: Tocal Silence Calculation
|
199 |
+
stats = SilenceStats.from_segments(final_output['ssm'])
|
200 |
+
t_std = stats.threshold_std(factor=0.99)
|
201 |
+
final_output["silence"] = t_std
|
202 |
+
|
203 |
+
print("Final_Output:", final_output)
|
204 |
+
|
205 |
+
# Step 17: Database
|
206 |
+
# Step 17.1: Insert File Table
|
207 |
+
summary = final_output.get("summary", "")
|
208 |
+
conflict_flag = 1 if final_output.get("conflict", False) else 0
|
209 |
+
silence_value = final_output.get("silence", 0.0)
|
210 |
+
detected_topic = final_output.get("topic", "Unknown")
|
211 |
+
|
212 |
+
topic_id = db.get_or_insert_topic_id(detected_topic, topics, db_topic_insert_path)
|
213 |
+
|
214 |
+
params = (
|
215 |
+
name,
|
216 |
+
topic_id,
|
217 |
+
file_extension,
|
218 |
+
absolute_file_path,
|
219 |
+
sample_rate,
|
220 |
+
min_frequency,
|
221 |
+
max_frequency,
|
222 |
+
audio_bit_depth,
|
223 |
+
num_channels,
|
224 |
+
audio_duration,
|
225 |
+
rms_loudness_db,
|
226 |
+
zero_crossing_rate_db,
|
227 |
+
spectral_centroid_db,
|
228 |
+
eq_20_250_db,
|
229 |
+
eq_250_2000_db,
|
230 |
+
eq_2000_6000_db,
|
231 |
+
eq_6000_20000_db,
|
232 |
+
*mfcc_values,
|
233 |
+
summary,
|
234 |
+
conflict_flag,
|
235 |
+
silence_value
|
236 |
+
)
|
237 |
+
|
238 |
+
last_id = db.insert(db_audio_properties_insert_path, params)
|
239 |
+
print(f"Audio properties inserted successfully into the File table with ID: {last_id}")
|
240 |
+
|
241 |
+
# Step 17.2: Insert Utterance Table
|
242 |
+
utterances = final_output["ssm"]
|
243 |
+
|
244 |
+
for utterance in utterances:
|
245 |
+
file_id = last_id
|
246 |
+
speaker = utterance["speaker"]
|
247 |
+
sequence = utterance["index"]
|
248 |
+
start_time = utterance["start_time"] / 1000.0
|
249 |
+
end_time = utterance["end_time"] / 1000.0
|
250 |
+
content = utterance["text"]
|
251 |
+
sentiment = utterance["sentiment"]
|
252 |
+
profane = 1 if utterance["profane"] else 0
|
253 |
+
|
254 |
+
utterance_params = (
|
255 |
+
file_id,
|
256 |
+
speaker,
|
257 |
+
sequence,
|
258 |
+
start_time,
|
259 |
+
end_time,
|
260 |
+
content,
|
261 |
+
sentiment,
|
262 |
+
profane
|
263 |
+
)
|
264 |
+
|
265 |
+
db.insert(db_utterance_insert_path, utterance_params)
|
266 |
+
|
267 |
+
print("Utterances inserted successfully into the Utterance table.")
|
268 |
+
|
269 |
+
# Step 18: Clean Up
|
270 |
+
cleaner.cleanup(temp_dir, audio_file_path)
|
271 |
+
|
272 |
+
|
273 |
+
async def process(path: str):
|
274 |
+
"""
|
275 |
+
Asynchronous callback function that is triggered when a new audio file is detected.
|
276 |
+
|
277 |
+
Parameters
|
278 |
+
----------
|
279 |
+
path : str
|
280 |
+
The path to the newly created audio file.
|
281 |
+
|
282 |
+
Returns
|
283 |
+
-------
|
284 |
+
None
|
285 |
+
"""
|
286 |
+
print(f"Processing new audio file: {path}")
|
287 |
+
await main(path)
|
288 |
+
|
289 |
+
|
290 |
+
if __name__ == "__main__":
|
291 |
+
directory_to_watch = ".data/input"
|
292 |
+
Watcher.start_watcher(directory_to_watch, process)
|
requirements.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
nemo_toolkit[asr]>=2.dev
|
2 |
+
nltk==3.9.1
|
3 |
+
faster-whisper==1.1.0
|
4 |
+
demucs==4.0.1
|
5 |
+
deepmultilingualpunctuation @ git+https://github.com/oliverguhr/deepmultilingualpunctuation.git@5a0dd7f4fd56687f59405aa8eba1144393d8b74b
|
6 |
+
ctc-forced-aligner @ git+https://github.com/MahmoudAshraf97/ctc-forced-aligner.git@c7cc7ce609e5f8f1f553fbd1e53124447ffe46d8
|
7 |
+
openai==1.57.0
|
8 |
+
accelerate>=0.26.0
|
9 |
+
torch==2.5.1
|
10 |
+
pydub==0.25.1
|
11 |
+
omegaconf==2.3.0
|
12 |
+
python-dotenv==1.0.1
|
13 |
+
transformers==4.47.0
|
14 |
+
librosa==0.10.2.post1
|
15 |
+
soundfile==0.12.1
|
16 |
+
noisereduce==3.0.3
|
17 |
+
numpy==1.26.4
|
18 |
+
pyannote.audio==3.3.2
|
19 |
+
watchdog==6.0.0
|
20 |
+
scipy==1.14.1
|
21 |
+
IPython==8.30.0
|
22 |
+
pyyaml==6.0.2
|
23 |
+
MPSENet==1.0.3
|
src/__init__.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import warnings
|
3 |
+
|
4 |
+
warnings.resetwarnings()
|
5 |
+
warnings.simplefilter("always")
|
src/audio/__init__.py
ADDED
File without changes
|
src/audio/alignment.py
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
from typing import Annotated, List, Dict
|
4 |
+
|
5 |
+
# Related third-party imports
|
6 |
+
import torch
|
7 |
+
from faster_whisper import decode_audio
|
8 |
+
from ctc_forced_aligner import (
|
9 |
+
generate_emissions,
|
10 |
+
get_alignments,
|
11 |
+
get_spans,
|
12 |
+
load_alignment_model,
|
13 |
+
postprocess_results,
|
14 |
+
preprocess_text,
|
15 |
+
)
|
16 |
+
|
17 |
+
|
18 |
+
class ForcedAligner:
|
19 |
+
"""
|
20 |
+
ForcedAligner is a class for aligning audio to a provided transcript using a pre-trained alignment model.
|
21 |
+
|
22 |
+
Attributes
|
23 |
+
----------
|
24 |
+
device : str
|
25 |
+
Device to run the model on ('cuda' for GPU or 'cpu').
|
26 |
+
alignment_model : torch.nn.Module
|
27 |
+
The pre-trained alignment model.
|
28 |
+
alignment_tokenizer : Any
|
29 |
+
Tokenizer for processing text in alignment.
|
30 |
+
|
31 |
+
Methods
|
32 |
+
-------
|
33 |
+
align(audio_path, transcript, language, batch_size)
|
34 |
+
Aligns audio with a transcript and returns word-level timing information.
|
35 |
+
"""
|
36 |
+
|
37 |
+
def __init__(self, device: Annotated[str, "Device for model ('cuda' or 'cpu')"] = None):
|
38 |
+
"""
|
39 |
+
Initialize the ForcedAligner with the specified device.
|
40 |
+
|
41 |
+
Parameters
|
42 |
+
----------
|
43 |
+
device : str, optional
|
44 |
+
Device for running the model, by default 'cuda' if available, otherwise 'cpu'.
|
45 |
+
"""
|
46 |
+
self.device = device or ('cuda' if torch.cuda.is_available() else 'cpu')
|
47 |
+
|
48 |
+
self.alignment_model, self.alignment_tokenizer = load_alignment_model(
|
49 |
+
self.device,
|
50 |
+
dtype=torch.float16 if self.device == 'cuda' else torch.float32,
|
51 |
+
)
|
52 |
+
|
53 |
+
def align(
|
54 |
+
self,
|
55 |
+
audio_path: Annotated[str, "Path to the audio file"],
|
56 |
+
transcript: Annotated[str, "Transcript of the audio content"],
|
57 |
+
language: Annotated[str, "Language of the transcript"] = 'en',
|
58 |
+
batch_size: Annotated[int, "Batch size for emission generation"] = 8,
|
59 |
+
) -> Annotated[List[Dict[str, float]], "List of word alignment data with timestamps"]:
|
60 |
+
"""
|
61 |
+
Aligns audio with a transcript and returns word-level timing information.
|
62 |
+
|
63 |
+
Parameters
|
64 |
+
----------
|
65 |
+
audio_path : str
|
66 |
+
Path to the audio file.
|
67 |
+
transcript : str
|
68 |
+
Transcript text corresponding to the audio.
|
69 |
+
language : str, optional
|
70 |
+
Language code for the transcript, default is 'en' (English).
|
71 |
+
batch_size : int, optional
|
72 |
+
Batch size for generating emissions, by default 8.
|
73 |
+
|
74 |
+
Returns
|
75 |
+
-------
|
76 |
+
List[Dict[str, float]]
|
77 |
+
A list of dictionaries containing word timing information.
|
78 |
+
|
79 |
+
Raises
|
80 |
+
------
|
81 |
+
FileNotFoundError
|
82 |
+
If the specified audio file does not exist.
|
83 |
+
|
84 |
+
Examples
|
85 |
+
--------
|
86 |
+
>>> aligner = ForcedAligner()
|
87 |
+
>>> aligner.align("path/to/audio.wav", "hello world")
|
88 |
+
[{'word': 'hello', 'start': 0.0, 'end': 0.5}, {'word': 'world', 'start': 0.6, 'end': 1.0}]
|
89 |
+
"""
|
90 |
+
if not os.path.exists(audio_path):
|
91 |
+
raise FileNotFoundError(
|
92 |
+
f"The audio file at path '{audio_path}' was not found."
|
93 |
+
)
|
94 |
+
|
95 |
+
speech_array = torch.from_numpy(decode_audio(audio_path))
|
96 |
+
|
97 |
+
emissions, stride = generate_emissions(
|
98 |
+
self.alignment_model,
|
99 |
+
speech_array.to(self.alignment_model.dtype).to(self.alignment_model.device),
|
100 |
+
batch_size=batch_size,
|
101 |
+
)
|
102 |
+
|
103 |
+
tokens_starred, text_starred = preprocess_text(
|
104 |
+
transcript,
|
105 |
+
romanize=True,
|
106 |
+
language=language,
|
107 |
+
)
|
108 |
+
|
109 |
+
segments, scores, blank_token = get_alignments(
|
110 |
+
emissions,
|
111 |
+
tokens_starred,
|
112 |
+
self.alignment_tokenizer,
|
113 |
+
)
|
114 |
+
|
115 |
+
spans = get_spans(tokens_starred, segments, blank_token)
|
116 |
+
|
117 |
+
word_timestamps = postprocess_results(text_starred, spans, stride, scores)
|
118 |
+
|
119 |
+
if self.device == 'cuda':
|
120 |
+
del self.alignment_model
|
121 |
+
torch.cuda.empty_cache()
|
122 |
+
|
123 |
+
print(f"Word_Timestamps: {word_timestamps}")
|
124 |
+
|
125 |
+
return word_timestamps
|
126 |
+
|
127 |
+
|
128 |
+
if __name__ == "__main__":
|
129 |
+
|
130 |
+
forced_aligner = ForcedAligner()
|
131 |
+
try:
|
132 |
+
path = "example_audio.wav"
|
133 |
+
audio_transcript = "This is a test transcript."
|
134 |
+
word_timestamp = forced_aligner.align(path, audio_transcript)
|
135 |
+
print(word_timestamp)
|
136 |
+
except FileNotFoundError as e:
|
137 |
+
print(e)
|
src/audio/analysis.py
ADDED
@@ -0,0 +1,715 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
import wave
|
4 |
+
from typing import List, Dict, Annotated, Union, Tuple
|
5 |
+
|
6 |
+
# Related third-party imports
|
7 |
+
import nltk
|
8 |
+
import numpy as np
|
9 |
+
import soundfile as sf
|
10 |
+
from librosa.feature import mfcc
|
11 |
+
from scipy.fft import fft, fftfreq
|
12 |
+
|
13 |
+
|
14 |
+
class WordSpeakerMapper:
|
15 |
+
"""
|
16 |
+
Maps words to speakers based on timestamps and aligns speaker tags after punctuation restoration.
|
17 |
+
|
18 |
+
This class processes word timing information and assigns each word to a speaker
|
19 |
+
based on the provided speaker timestamps. Missing timestamps are handled, and each
|
20 |
+
word can be aligned to a speaker based on different reference points ('start', 'mid', or 'end').
|
21 |
+
After punctuation restoration, word-speaker mapping can be realigned to ensure consistency
|
22 |
+
within a sentence.
|
23 |
+
|
24 |
+
Attributes
|
25 |
+
----------
|
26 |
+
word_timestamps : List[Dict]
|
27 |
+
List of word timing information with 'start', 'end', and 'text' keys.
|
28 |
+
speaker_timestamps : List[List[int]]
|
29 |
+
List of speaker segments, where each segment contains [start_time, end_time, speaker_id].
|
30 |
+
word_speaker_mapping : List[Dict] or None
|
31 |
+
Processed word-to-speaker mappings.
|
32 |
+
|
33 |
+
Methods
|
34 |
+
-------
|
35 |
+
filter_missing_timestamps(word_timestamps, initial_timestamp=0, final_timestamp=None)
|
36 |
+
Fills in missing start and end timestamps in word timing data.
|
37 |
+
get_words_speaker_mapping(word_anchor_option='start')
|
38 |
+
Maps words to speakers based on word and speaker timestamps.
|
39 |
+
"""
|
40 |
+
|
41 |
+
def __init__(
|
42 |
+
self,
|
43 |
+
word_timestamps: Annotated[List[Dict], "List of word timing information"],
|
44 |
+
speaker_timestamps: Annotated[List[List[Union[int, float]]], "List of speaker segments"],
|
45 |
+
):
|
46 |
+
"""
|
47 |
+
Initializes the WordSpeakerMapper with word and speaker timestamps.
|
48 |
+
|
49 |
+
Parameters
|
50 |
+
----------
|
51 |
+
word_timestamps : List[Dict]
|
52 |
+
List of word timing information.
|
53 |
+
speaker_timestamps : List[List[int]]
|
54 |
+
List of speaker segments.
|
55 |
+
"""
|
56 |
+
self.word_timestamps = self.filter_missing_timestamps(word_timestamps)
|
57 |
+
self.speaker_timestamps = speaker_timestamps
|
58 |
+
self.word_speaker_mapping = None
|
59 |
+
|
60 |
+
def filter_missing_timestamps(
|
61 |
+
self,
|
62 |
+
word_timestamps: Annotated[List[Dict], "List of word timing information"],
|
63 |
+
initial_timestamp: Annotated[int, "Start time of the first word"] = 0,
|
64 |
+
final_timestamp: Annotated[int, "End time of the last word"] = None
|
65 |
+
) -> Annotated[List[Dict], "List of word timestamps with missing values filled"]:
|
66 |
+
"""
|
67 |
+
Fills in missing start and end timestamps.
|
68 |
+
|
69 |
+
Parameters
|
70 |
+
----------
|
71 |
+
word_timestamps : List[Dict]
|
72 |
+
List of word timing information that may contain missing timestamps.
|
73 |
+
initial_timestamp : int, optional
|
74 |
+
Start time of the first word, default is 0.
|
75 |
+
final_timestamp : int, optional
|
76 |
+
End time of the last word, if available.
|
77 |
+
|
78 |
+
Returns
|
79 |
+
-------
|
80 |
+
List[Dict]
|
81 |
+
List of word timestamps with missing values filled.
|
82 |
+
|
83 |
+
Examples
|
84 |
+
--------
|
85 |
+
>>> word_timestamp = [{'text': 'Hello', 'end': 1.2}]
|
86 |
+
>>> mapper = WordSpeakerMapper([], [])
|
87 |
+
>>> mapper.filter_missing_timestamps(word_timestamps)
|
88 |
+
[{'text': 'Hello', 'start': 0, 'end': 1.2}]
|
89 |
+
"""
|
90 |
+
if word_timestamps[0].get("start") is None:
|
91 |
+
word_timestamps[0]["start"] = initial_timestamp
|
92 |
+
word_timestamps[0]["end"] = self._get_next_start_timestamp(word_timestamps, 0, final_timestamp)
|
93 |
+
|
94 |
+
result = [word_timestamps[0]]
|
95 |
+
|
96 |
+
for i, ws in enumerate(word_timestamps[1:], start=1):
|
97 |
+
if "text" not in ws:
|
98 |
+
continue
|
99 |
+
|
100 |
+
if ws.get("start") is None:
|
101 |
+
ws["start"] = word_timestamps[i - 1]["end"]
|
102 |
+
ws["end"] = self._get_next_start_timestamp(word_timestamps, i, final_timestamp)
|
103 |
+
|
104 |
+
if ws["text"] is not None:
|
105 |
+
result.append(ws)
|
106 |
+
return result
|
107 |
+
|
108 |
+
@staticmethod
|
109 |
+
def _get_next_start_timestamp(
|
110 |
+
word_timestamps: Annotated[List[Dict], "List of word timing information"],
|
111 |
+
current_word_index: Annotated[int, "Index of the current word"],
|
112 |
+
final_timestamp: Annotated[int, "Final timestamp if needed"]
|
113 |
+
) -> Annotated[int, "Next start timestamp for filling missing values"]:
|
114 |
+
"""
|
115 |
+
Finds the next start timestamp to fill in missing values.
|
116 |
+
|
117 |
+
Parameters
|
118 |
+
----------
|
119 |
+
word_timestamps : List[Dict]
|
120 |
+
List of word timing information.
|
121 |
+
current_word_index : int
|
122 |
+
Index of the current word.
|
123 |
+
final_timestamp : int, optional
|
124 |
+
Final timestamp to use if no next timestamp is found.
|
125 |
+
|
126 |
+
Returns
|
127 |
+
-------
|
128 |
+
int
|
129 |
+
Next start timestamp for filling missing values.
|
130 |
+
|
131 |
+
Examples
|
132 |
+
--------
|
133 |
+
>>> word_timestamp = [{'start': 0.5, 'text': 'Hello'}, {'end': 2.0}]
|
134 |
+
>>> mapper = WordSpeakerMapper([], [])
|
135 |
+
>>> mapper._get_next_start_timestamp(word_timestamps, 0, 2)
|
136 |
+
"""
|
137 |
+
if current_word_index == len(word_timestamps) - 1:
|
138 |
+
return word_timestamps[current_word_index]["start"]
|
139 |
+
|
140 |
+
next_word_index = current_word_index + 1
|
141 |
+
while next_word_index < len(word_timestamps):
|
142 |
+
if word_timestamps[next_word_index].get("start") is None:
|
143 |
+
word_timestamps[current_word_index]["text"] += (
|
144 |
+
" " + word_timestamps[next_word_index]["text"]
|
145 |
+
)
|
146 |
+
word_timestamps[next_word_index]["text"] = None
|
147 |
+
next_word_index += 1
|
148 |
+
if next_word_index == len(word_timestamps):
|
149 |
+
return final_timestamp
|
150 |
+
else:
|
151 |
+
return word_timestamps[next_word_index]["start"]
|
152 |
+
return final_timestamp
|
153 |
+
|
154 |
+
def get_words_speaker_mapping(self, word_anchor_option='start') -> List[Dict]:
|
155 |
+
"""
|
156 |
+
Maps words to speakers based on their timestamps.
|
157 |
+
|
158 |
+
Parameters
|
159 |
+
----------
|
160 |
+
word_anchor_option : str, optional
|
161 |
+
Anchor point for word mapping ('start', 'mid', or 'end'), default is 'start'.
|
162 |
+
|
163 |
+
Returns
|
164 |
+
-------
|
165 |
+
List[Dict]
|
166 |
+
List of word-to-speaker mappings with timestamps and speaker IDs.
|
167 |
+
|
168 |
+
Examples
|
169 |
+
--------
|
170 |
+
>>> word_timestamps = [{'start': 0.5, 'end': 1.2, 'text': 'Hello'}]
|
171 |
+
>>> speaker_timestamps = [[0, 1000, 1]]
|
172 |
+
>>> mapper = WordSpeakerMapper(word_timestamps, speaker_timestamps)
|
173 |
+
>>> mapper.get_words_speaker_mapping()
|
174 |
+
[{'text': 'Hello', 'start_time': 500, 'end_time': 1200, 'speaker': 1}]
|
175 |
+
"""
|
176 |
+
|
177 |
+
def get_word_ts_anchor(start: int, end: int, option: str) -> int:
|
178 |
+
"""
|
179 |
+
Determines the anchor timestamp for a word.
|
180 |
+
|
181 |
+
Parameters
|
182 |
+
----------
|
183 |
+
start : int
|
184 |
+
Start time of the word in milliseconds.
|
185 |
+
end : int
|
186 |
+
End time of the word in milliseconds.
|
187 |
+
option : str
|
188 |
+
Anchor point for timestamp calculation ('start', 'mid', or 'end').
|
189 |
+
|
190 |
+
Returns
|
191 |
+
-------
|
192 |
+
int
|
193 |
+
Anchor timestamp for the word.
|
194 |
+
|
195 |
+
Examples
|
196 |
+
--------
|
197 |
+
>>> get_word_ts_anchor(500, 1200, 'mid')
|
198 |
+
850
|
199 |
+
"""
|
200 |
+
if option == "end":
|
201 |
+
return end
|
202 |
+
elif option == "mid":
|
203 |
+
return (start + end) // 2
|
204 |
+
return start
|
205 |
+
|
206 |
+
wrd_spk_mapping = []
|
207 |
+
turn_idx = 0
|
208 |
+
num_speaker_ts = len(self.speaker_timestamps)
|
209 |
+
|
210 |
+
for wrd_dict in self.word_timestamps:
|
211 |
+
ws, we, wrd = (
|
212 |
+
int(wrd_dict["start"] * 1000),
|
213 |
+
int(wrd_dict["end"] * 1000),
|
214 |
+
wrd_dict["text"],
|
215 |
+
)
|
216 |
+
wrd_pos = get_word_ts_anchor(ws, we, word_anchor_option)
|
217 |
+
|
218 |
+
sp = -1
|
219 |
+
|
220 |
+
while turn_idx < num_speaker_ts and wrd_pos > self.speaker_timestamps[turn_idx][1]:
|
221 |
+
turn_idx += 1
|
222 |
+
|
223 |
+
if turn_idx < num_speaker_ts and self.speaker_timestamps[turn_idx][0] <= wrd_pos <= \
|
224 |
+
self.speaker_timestamps[turn_idx][1]:
|
225 |
+
sp = self.speaker_timestamps[turn_idx][2]
|
226 |
+
elif turn_idx > 0:
|
227 |
+
sp = self.speaker_timestamps[turn_idx - 1][2]
|
228 |
+
|
229 |
+
wrd_spk_mapping.append(
|
230 |
+
{"text": wrd, "start_time": ws, "end_time": we, "speaker": sp}
|
231 |
+
)
|
232 |
+
|
233 |
+
self.word_speaker_mapping = wrd_spk_mapping
|
234 |
+
return self.word_speaker_mapping
|
235 |
+
|
236 |
+
def realign_with_punctuation(self, max_words_in_sentence: int = 50) -> None:
|
237 |
+
"""
|
238 |
+
Realigns word-speaker mapping after punctuation restoration.
|
239 |
+
|
240 |
+
This method ensures consistent speaker mapping within sentences by analyzing
|
241 |
+
punctuation and adjusting speaker labels for words that are part of the same sentence.
|
242 |
+
|
243 |
+
Parameters
|
244 |
+
----------
|
245 |
+
max_words_in_sentence : int, optional
|
246 |
+
Maximum number of words to consider for realignment in a sentence,
|
247 |
+
default is 50.
|
248 |
+
|
249 |
+
Examples
|
250 |
+
--------
|
251 |
+
>>> word_speaker_mapping = [
|
252 |
+
... {"text": "Hello", "speaker": "Speaker 1"},
|
253 |
+
... {"text": "world", "speaker": "Speaker 2"},
|
254 |
+
... {"text": ".", "speaker": "Speaker 2"},
|
255 |
+
... {"text": "How", "speaker": "Speaker 1"},
|
256 |
+
... {"text": "are", "speaker": "Speaker 1"},
|
257 |
+
... {"text": "you", "speaker": "Speaker 2"},
|
258 |
+
... {"text": "?", "speaker": "Speaker 2"}
|
259 |
+
... ]
|
260 |
+
>>> mapper = WordSpeakerMapper([], [])
|
261 |
+
>>> mapper.word_speaker_mapping = word_speaker_mapping
|
262 |
+
>>> mapper.realign_with_punctuation()
|
263 |
+
>>> print(mapper.word_speaker_mapping)
|
264 |
+
[{'text': 'Hello', 'speaker': 'Speaker 1'},
|
265 |
+
{'text': 'world', 'speaker': 'Speaker 1'},
|
266 |
+
{'text': '.', 'speaker': 'Speaker 1'},
|
267 |
+
{'text': 'How', 'speaker': 'Speaker 1'},
|
268 |
+
{'text': 'are', 'speaker': 'Speaker 1'},
|
269 |
+
{'text': 'you', 'speaker': 'Speaker 1'},
|
270 |
+
{'text': '?', 'speaker': 'Speaker 1'}]
|
271 |
+
"""
|
272 |
+
sentence_ending_punctuations = ".?!"
|
273 |
+
|
274 |
+
def is_word_sentence_end(word_index: Annotated[int, "Index of the word to check"]) -> Annotated[
|
275 |
+
bool, "True if the word is a sentence end, False otherwise"]:
|
276 |
+
"""
|
277 |
+
Checks if a word is the end of a sentence based on punctuation.
|
278 |
+
|
279 |
+
This method determines whether a word at the given index marks
|
280 |
+
the end of a sentence by checking if the last character of the
|
281 |
+
word is a sentence-ending punctuation (e.g., '.', '!', or '?').
|
282 |
+
|
283 |
+
Parameters
|
284 |
+
----------
|
285 |
+
word_index : int
|
286 |
+
Index of the word to check in the `word_speaker_mapping`.
|
287 |
+
|
288 |
+
Returns
|
289 |
+
-------
|
290 |
+
bool
|
291 |
+
True if the word at the given index is the end of a sentence,
|
292 |
+
False otherwise.
|
293 |
+
|
294 |
+
"""
|
295 |
+
return (
|
296 |
+
word_index >= 0
|
297 |
+
and self.word_speaker_mapping[word_index]["text"][-1] in sentence_ending_punctuations
|
298 |
+
)
|
299 |
+
|
300 |
+
wsp_len = len(self.word_speaker_mapping)
|
301 |
+
words_list = [wd['text'] for wd in self.word_speaker_mapping]
|
302 |
+
speaker_list = [wd['speaker'] for wd in self.word_speaker_mapping]
|
303 |
+
|
304 |
+
k = 0
|
305 |
+
while k < len(self.word_speaker_mapping):
|
306 |
+
if (
|
307 |
+
k < wsp_len - 1
|
308 |
+
and speaker_list[k] != speaker_list[k + 1]
|
309 |
+
and not is_word_sentence_end(k)
|
310 |
+
):
|
311 |
+
left_idx = self._get_first_word_idx_of_sentence(
|
312 |
+
k, words_list, speaker_list, max_words_in_sentence
|
313 |
+
)
|
314 |
+
right_idx = (
|
315 |
+
self._get_last_word_idx_of_sentence(
|
316 |
+
k, words_list, max_words_in_sentence - (k - left_idx) - 1
|
317 |
+
)
|
318 |
+
if left_idx > -1
|
319 |
+
else -1
|
320 |
+
)
|
321 |
+
if min(left_idx, right_idx) == -1:
|
322 |
+
k += 1
|
323 |
+
continue
|
324 |
+
|
325 |
+
spk_labels = speaker_list[left_idx:right_idx + 1]
|
326 |
+
mod_speaker = max(set(spk_labels), key=spk_labels.count)
|
327 |
+
if spk_labels.count(mod_speaker) < len(spk_labels) // 2:
|
328 |
+
k += 1
|
329 |
+
continue
|
330 |
+
|
331 |
+
speaker_list[left_idx:right_idx + 1] = [mod_speaker] * (
|
332 |
+
right_idx - left_idx + 1
|
333 |
+
)
|
334 |
+
k = right_idx
|
335 |
+
|
336 |
+
k += 1
|
337 |
+
|
338 |
+
for idx in range(len(self.word_speaker_mapping)):
|
339 |
+
self.word_speaker_mapping[idx]["speaker"] = speaker_list[idx]
|
340 |
+
|
341 |
+
@staticmethod
|
342 |
+
def _get_first_word_idx_of_sentence(
|
343 |
+
word_idx: int, word_list: List[str], speaker_list: List[str], max_words: int
|
344 |
+
) -> int:
|
345 |
+
"""
|
346 |
+
Finds the first word index of a sentence for realignment.
|
347 |
+
|
348 |
+
Parameters
|
349 |
+
----------
|
350 |
+
word_idx : int
|
351 |
+
Current word index.
|
352 |
+
word_list : List[str]
|
353 |
+
List of words in the sentence.
|
354 |
+
speaker_list : List[str]
|
355 |
+
List of speakers for the words.
|
356 |
+
max_words : int
|
357 |
+
Maximum words to consider in the sentence.
|
358 |
+
|
359 |
+
Returns
|
360 |
+
-------
|
361 |
+
int
|
362 |
+
The index of the first word of the sentence.
|
363 |
+
|
364 |
+
Examples
|
365 |
+
--------
|
366 |
+
>>> words_list = ["Hello", "world", ".", "How", "are", "you", "?"]
|
367 |
+
>>> speakers_list = ["Speaker 1", "Speaker 1", "Speaker 1", "Speaker 2", "Speaker 2", "Speaker 2", "Speaker 2"]
|
368 |
+
>>> WordSpeakerMapper._get_first_word_idx_of_sentence(4, word_list, speaker_list, 50)
|
369 |
+
3
|
370 |
+
"""
|
371 |
+
sentence_ending_punctuations = ".?!"
|
372 |
+
is_word_sentence_end = (
|
373 |
+
lambda x: x >= 0 and word_list[x][-1] in sentence_ending_punctuations
|
374 |
+
)
|
375 |
+
left_idx = word_idx
|
376 |
+
while (
|
377 |
+
left_idx > 0
|
378 |
+
and word_idx - left_idx < max_words
|
379 |
+
and speaker_list[left_idx - 1] == speaker_list[left_idx]
|
380 |
+
and not is_word_sentence_end(left_idx - 1)
|
381 |
+
):
|
382 |
+
left_idx -= 1
|
383 |
+
|
384 |
+
return left_idx if left_idx == 0 or is_word_sentence_end(left_idx - 1) else -1
|
385 |
+
|
386 |
+
@staticmethod
|
387 |
+
def _get_last_word_idx_of_sentence(
|
388 |
+
word_idx: int, word_list: List[str], max_words: int
|
389 |
+
) -> int:
|
390 |
+
"""
|
391 |
+
Finds the last word index of a sentence for realignment.
|
392 |
+
|
393 |
+
Parameters
|
394 |
+
----------
|
395 |
+
word_idx : int
|
396 |
+
Current word index.
|
397 |
+
word_list : List[str]
|
398 |
+
List of words in the sentence.
|
399 |
+
max_words : int
|
400 |
+
Maximum words to consider in the sentence.
|
401 |
+
|
402 |
+
Returns
|
403 |
+
-------
|
404 |
+
int
|
405 |
+
The index of the last word of the sentence.
|
406 |
+
|
407 |
+
Examples
|
408 |
+
--------
|
409 |
+
>>> words_list = ["Hello", "world", ".", "How", "are", "you", "?"]
|
410 |
+
>>> WordSpeakerMapper._get_last_word_idx_of_sentence(3, word_list, 50)
|
411 |
+
6
|
412 |
+
"""
|
413 |
+
sentence_ending_punctuations = ".?!"
|
414 |
+
is_word_sentence_end = (
|
415 |
+
lambda x: x >= 0 and word_list[x][-1] in sentence_ending_punctuations
|
416 |
+
)
|
417 |
+
right_idx = word_idx
|
418 |
+
while (
|
419 |
+
right_idx < len(word_list) - 1
|
420 |
+
and right_idx - word_idx < max_words
|
421 |
+
and not is_word_sentence_end(right_idx)
|
422 |
+
):
|
423 |
+
right_idx += 1
|
424 |
+
|
425 |
+
return (
|
426 |
+
right_idx
|
427 |
+
if right_idx == len(word_list) - 1 or is_word_sentence_end(right_idx)
|
428 |
+
else -1
|
429 |
+
)
|
430 |
+
|
431 |
+
|
432 |
+
class SentenceSpeakerMapper:
|
433 |
+
"""
|
434 |
+
Groups words into sentences and assigns each sentence to a speaker.
|
435 |
+
|
436 |
+
This class uses word-speaker mapping to group words into sentences based on punctuation
|
437 |
+
and speaker changes. It uses the NLTK library to detect sentence boundaries.
|
438 |
+
|
439 |
+
Attributes
|
440 |
+
----------
|
441 |
+
sentence_checker : Callable
|
442 |
+
Function to check for sentence breaks.
|
443 |
+
sentence_ending_punctuations : str
|
444 |
+
String of punctuation characters that indicate sentence endings.
|
445 |
+
|
446 |
+
Methods
|
447 |
+
-------
|
448 |
+
get_sentences_speaker_mapping(word_speaker_mapping)
|
449 |
+
Groups words into sentences and assigns each sentence to a speaker.
|
450 |
+
"""
|
451 |
+
|
452 |
+
def __init__(self):
|
453 |
+
"""
|
454 |
+
Initializes the SentenceSpeakerMapper and downloads required NLTK resources.
|
455 |
+
"""
|
456 |
+
nltk.download('punkt', quiet=True)
|
457 |
+
self.sentence_checker = nltk.tokenize.PunktSentenceTokenizer().text_contains_sentbreak
|
458 |
+
self.sentence_ending_punctuations = ".?!"
|
459 |
+
|
460 |
+
def get_sentences_speaker_mapping(
|
461 |
+
self,
|
462 |
+
word_speaker_mapping: Annotated[List[Dict], "List of words with speaker labels"]
|
463 |
+
) -> Annotated[List[Dict], "List of sentences with speaker labels and timing information"]:
|
464 |
+
"""
|
465 |
+
Groups words into sentences and assigns each sentence to a speaker.
|
466 |
+
|
467 |
+
Parameters
|
468 |
+
----------
|
469 |
+
word_speaker_mapping : List[Dict]
|
470 |
+
List of words with speaker labels.
|
471 |
+
|
472 |
+
Returns
|
473 |
+
-------
|
474 |
+
List[Dict]
|
475 |
+
List of sentences with speaker labels and timing information.
|
476 |
+
|
477 |
+
Examples
|
478 |
+
--------
|
479 |
+
>>> sentence_mapper = SentenceSpeakerMapper()
|
480 |
+
>>> word_speaker_map = [
|
481 |
+
... {'text': 'Hello', 'start_time': 0, 'end_time': 500, 'speaker': 1},
|
482 |
+
... {'text': 'world.', 'start_time': 600, 'end_time': 1000, 'speaker': 1},
|
483 |
+
... {'text': 'How', 'start_time': 1100, 'end_time': 1300, 'speaker': 2},
|
484 |
+
... {'text': 'are', 'start_time': 1400, 'end_time': 1500, 'speaker': 2},
|
485 |
+
... {'text': 'you?', 'start_time': 1600, 'end_time': 2000, 'speaker': 2},
|
486 |
+
... ]
|
487 |
+
>>> sentence_mapper.get_sentences_speaker_mapping(word_speaker_mapping)
|
488 |
+
[{'speaker': 'Speaker 1', 'start_time': 0, 'end_time': 1000, 'text': 'Hello world. '},
|
489 |
+
{'speaker': 'Speaker 2', 'start_time': 1100, 'end_time': 2000, 'text': 'How are you?'}]
|
490 |
+
"""
|
491 |
+
snts = []
|
492 |
+
prev_spk = word_speaker_mapping[0]['speaker']
|
493 |
+
snt = {
|
494 |
+
"speaker": f"Speaker {prev_spk}",
|
495 |
+
"start_time": word_speaker_mapping[0]['start_time'],
|
496 |
+
"end_time": word_speaker_mapping[0]['end_time'],
|
497 |
+
"text": word_speaker_mapping[0]['text'] + " ",
|
498 |
+
}
|
499 |
+
|
500 |
+
for word_dict in word_speaker_mapping[1:]:
|
501 |
+
word, spk = word_dict["text"], word_dict["speaker"]
|
502 |
+
s, e = word_dict["start_time"], word_dict["end_time"]
|
503 |
+
if spk != prev_spk or self.sentence_checker(snt["text"] + word):
|
504 |
+
snts.append(snt)
|
505 |
+
snt = {
|
506 |
+
"speaker": f"Speaker {spk}",
|
507 |
+
"start_time": s,
|
508 |
+
"end_time": e,
|
509 |
+
"text": word + " ",
|
510 |
+
}
|
511 |
+
else:
|
512 |
+
snt["end_time"] = e
|
513 |
+
snt["text"] += word + " "
|
514 |
+
prev_spk = spk
|
515 |
+
|
516 |
+
snts.append(snt)
|
517 |
+
return snts
|
518 |
+
|
519 |
+
|
520 |
+
class Audio:
|
521 |
+
"""
|
522 |
+
A class to handle audio file analysis and property extraction.
|
523 |
+
|
524 |
+
This class provides methods to load an audio file, process it, and
|
525 |
+
extract various audio properties including spectral, temporal, and
|
526 |
+
perceptual features.
|
527 |
+
|
528 |
+
Parameters
|
529 |
+
----------
|
530 |
+
audio_path : str
|
531 |
+
Path to the audio file to be analyzed.
|
532 |
+
|
533 |
+
Attributes
|
534 |
+
----------
|
535 |
+
audio_path : str
|
536 |
+
Path to the audio file.
|
537 |
+
extension : str
|
538 |
+
File extension of the audio file.
|
539 |
+
samples : int
|
540 |
+
Total number of audio samples.
|
541 |
+
duration : float
|
542 |
+
Duration of the audio in seconds.
|
543 |
+
data : np.ndarray
|
544 |
+
Audio data loaded from the file.
|
545 |
+
rate : int
|
546 |
+
Sampling rate of the audio file.
|
547 |
+
"""
|
548 |
+
|
549 |
+
def __init__(self, audio_path: str):
|
550 |
+
"""
|
551 |
+
Initialize the Audio class with a given audio file path.
|
552 |
+
|
553 |
+
Parameters
|
554 |
+
----------
|
555 |
+
audio_path : str
|
556 |
+
Path to the audio file.
|
557 |
+
|
558 |
+
Raises
|
559 |
+
------
|
560 |
+
TypeError
|
561 |
+
If `audio_path` is not a non-empty string.
|
562 |
+
FileNotFoundError
|
563 |
+
If the file specified by `audio_path` does not exist.
|
564 |
+
ValueError
|
565 |
+
If the file has an unsupported extension or is empty.
|
566 |
+
RuntimeError
|
567 |
+
If there is an error reading the audio file.
|
568 |
+
"""
|
569 |
+
if not isinstance(audio_path, str) or not audio_path:
|
570 |
+
raise TypeError("audio_path must be a non-empty string")
|
571 |
+
|
572 |
+
if not os.path.isfile(audio_path):
|
573 |
+
raise FileNotFoundError(f"The specified audio file does not exist: {audio_path}")
|
574 |
+
|
575 |
+
valid_extensions = [".wav", ".flac", ".mp3", ".ogg", ".m4a", ".aac"]
|
576 |
+
extension = os.path.splitext(audio_path)[1].lower()
|
577 |
+
if extension not in valid_extensions:
|
578 |
+
raise ValueError(f"File extension {extension} is not recognized as a supported audio format.")
|
579 |
+
|
580 |
+
try:
|
581 |
+
self.data, self.rate = sf.read(audio_path, dtype='float32')
|
582 |
+
except RuntimeError as e:
|
583 |
+
raise RuntimeError(f"Error reading audio file: {audio_path}") from e
|
584 |
+
|
585 |
+
if len(self.data) == 0:
|
586 |
+
raise ValueError(f"Audio file is empty: {audio_path}")
|
587 |
+
|
588 |
+
# Convert stereo or multichannel audio to mono
|
589 |
+
if len(self.data.shape) > 1 and self.data.shape[1] > 1:
|
590 |
+
self.data = np.mean(self.data, axis=1)
|
591 |
+
|
592 |
+
self.audio_path = audio_path
|
593 |
+
self.extension = extension
|
594 |
+
self.samples = len(self.data)
|
595 |
+
self.duration = self.samples / self.rate
|
596 |
+
|
597 |
+
def properties(self) -> Tuple[
|
598 |
+
str, str, str, int, float, float, Union[int, None], int, float, float, Dict[str, float]]:
|
599 |
+
"""
|
600 |
+
Extract various properties and features from the audio file.
|
601 |
+
|
602 |
+
Returns
|
603 |
+
-------
|
604 |
+
Tuple[str, str, str, int, float, float, Union[int, None], int, float, float, Dict[str, float]]
|
605 |
+
A tuple containing:
|
606 |
+
- File name (str)
|
607 |
+
- File extension (str)
|
608 |
+
- File path (str)
|
609 |
+
- Sample rate (int)
|
610 |
+
- Minimum frequency (float)
|
611 |
+
- Maximum frequency (float)
|
612 |
+
- Bit depth (Union[int, None])
|
613 |
+
- Number of channels (int)
|
614 |
+
- Duration (float)
|
615 |
+
- Root mean square loudness (float)
|
616 |
+
- A dictionary of extracted properties (Dict[str, float])
|
617 |
+
|
618 |
+
Notes
|
619 |
+
-----
|
620 |
+
Properties extracted include:
|
621 |
+
- Spectral bands energy
|
622 |
+
- Zero Crossing Rate (ZCR)
|
623 |
+
- Spectral Centroid
|
624 |
+
- MFCCs (Mel Frequency Cepstral Coefficients)
|
625 |
+
|
626 |
+
Examples
|
627 |
+
--------
|
628 |
+
>>> audio = Audio("sample.wav")
|
629 |
+
>>> audio.properties()
|
630 |
+
('sample.wav', '.wav', '/path/to/sample.wav', 44100, 20.0, 20000.0, 16, 2, 5.2, 0.25, {...})
|
631 |
+
"""
|
632 |
+
bands = [(20, 250), (250, 2000), (2000, 6000), (6000, 20000)]
|
633 |
+
|
634 |
+
x = fft(self.data)
|
635 |
+
xf = fftfreq(self.samples, 1 / self.rate)
|
636 |
+
|
637 |
+
nonzero_indices = np.where(xf != 0)[0]
|
638 |
+
min_freq = np.min(np.abs(xf[nonzero_indices]))
|
639 |
+
max_freq = np.max(np.abs(xf))
|
640 |
+
|
641 |
+
bit_depth = None
|
642 |
+
if self.extension == ".wav":
|
643 |
+
with wave.open(self.audio_path, 'r') as wav_file:
|
644 |
+
bit_depth = wav_file.getsampwidth() * 8
|
645 |
+
channels = wav_file.getnchannels()
|
646 |
+
else:
|
647 |
+
info = sf.info(self.audio_path)
|
648 |
+
channels = info.channels
|
649 |
+
|
650 |
+
duration = float(self.duration)
|
651 |
+
loudness = np.sqrt(np.mean(self.data ** 2))
|
652 |
+
|
653 |
+
s = np.abs(x)
|
654 |
+
freqs = xf
|
655 |
+
eq_properties = {}
|
656 |
+
for band in bands:
|
657 |
+
band_mask = (freqs >= band[0]) & (freqs <= band[1])
|
658 |
+
band_data = s[band_mask]
|
659 |
+
band_energy = np.mean(band_data ** 2, axis=0) if band_data.size > 0 else 0
|
660 |
+
eq_properties[f"EQ_{band[0]}_{band[1]}_Hz"] = band_energy
|
661 |
+
|
662 |
+
zcr = np.sum(np.abs(np.diff(np.sign(self.data)))) / len(self.data)
|
663 |
+
|
664 |
+
magnitude_spectrum = np.abs(np.fft.rfft(self.data))
|
665 |
+
freqs_centroid = np.fft.rfftfreq(len(self.data), 1.0 / self.rate)
|
666 |
+
spectral_centroid = (np.sum(freqs_centroid * magnitude_spectrum) /
|
667 |
+
np.sum(magnitude_spectrum)) if np.sum(magnitude_spectrum) != 0 else 0.0
|
668 |
+
|
669 |
+
mfccs = mfcc(y=self.data, sr=self.rate, n_mfcc=13)
|
670 |
+
|
671 |
+
mfcc_mean = np.mean(mfccs, axis=1)
|
672 |
+
|
673 |
+
eq_properties["RMSLoudness"] = float(loudness)
|
674 |
+
eq_properties["ZeroCrossingRate"] = float(zcr)
|
675 |
+
eq_properties["SpectralCentroid"] = float(spectral_centroid)
|
676 |
+
for i, val in enumerate(mfcc_mean):
|
677 |
+
eq_properties[f"MFCC_{i + 1}"] = float(val)
|
678 |
+
|
679 |
+
eq_properties_converted = {key: float(value) for key, value in eq_properties.items()}
|
680 |
+
|
681 |
+
file_name = os.path.basename(self.audio_path)
|
682 |
+
path = os.path.abspath(self.audio_path)
|
683 |
+
|
684 |
+
bit_depth = int(bit_depth) if bit_depth is not None else None
|
685 |
+
channels = int(channels) if channels is not None else 1
|
686 |
+
|
687 |
+
return (
|
688 |
+
file_name,
|
689 |
+
self.extension,
|
690 |
+
path,
|
691 |
+
int(self.rate),
|
692 |
+
float(min_freq),
|
693 |
+
float(max_freq),
|
694 |
+
bit_depth,
|
695 |
+
channels,
|
696 |
+
float(duration),
|
697 |
+
float(loudness),
|
698 |
+
eq_properties_converted
|
699 |
+
)
|
700 |
+
|
701 |
+
|
702 |
+
if __name__ == "__main__":
|
703 |
+
words_timestamp = [
|
704 |
+
{'text': 'Hello', 'start': 0.0, 'end': 1.2},
|
705 |
+
{'text': 'world', 'start': 1.3, 'end': 2.0}
|
706 |
+
]
|
707 |
+
speaker_timestamp = [
|
708 |
+
[0.0, 1.5, 1],
|
709 |
+
[1.6, 3.0, 2]
|
710 |
+
]
|
711 |
+
|
712 |
+
word_sentence_mapper = WordSpeakerMapper(words_timestamp, speaker_timestamp)
|
713 |
+
word_speaker_maps = word_sentence_mapper.get_words_speaker_mapping()
|
714 |
+
print("Word-Speaker Mapping:")
|
715 |
+
print(word_speaker_maps)
|
src/audio/effect.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
import warnings
|
4 |
+
from typing import Annotated, Optional
|
5 |
+
|
6 |
+
# Related third-party imports
|
7 |
+
import demucs.separate
|
8 |
+
|
9 |
+
|
10 |
+
class DemucsVocalSeparator:
|
11 |
+
"""
|
12 |
+
A class for separating vocals from an audio file using the Demucs model.
|
13 |
+
|
14 |
+
This class utilizes the Demucs model to separate specified audio stems (e.g., vocals) from an input audio file.
|
15 |
+
It supports saving the separated outputs to a specified directory.
|
16 |
+
|
17 |
+
Attributes
|
18 |
+
----------
|
19 |
+
model_name : str
|
20 |
+
Name of the Demucs model to use for separation.
|
21 |
+
two_stems : str
|
22 |
+
The stem to isolate (e.g., "vocals").
|
23 |
+
|
24 |
+
Methods
|
25 |
+
-------
|
26 |
+
separate_vocals(audio_file: str, output_dir: str) -> Optional[str]
|
27 |
+
Separates vocals (or other specified stem) from the audio file and returns the path to the separated file.
|
28 |
+
|
29 |
+
"""
|
30 |
+
|
31 |
+
def __init__(
|
32 |
+
self,
|
33 |
+
model_name: Annotated[str, "Demucs model name to use for separation"] = "htdemucs",
|
34 |
+
two_stems: Annotated[str, "Stem to isolate (e.g., vocals, drums)"] = "vocals"
|
35 |
+
):
|
36 |
+
"""
|
37 |
+
Initializes the DemucsVocalSeparator with the given parameters.
|
38 |
+
|
39 |
+
Parameters
|
40 |
+
----------
|
41 |
+
model_name : str, optional
|
42 |
+
Name of the Demucs model to use for separation (default is "htdemucs").
|
43 |
+
two_stems : str, optional
|
44 |
+
The stem to isolate (default is "vocals").
|
45 |
+
"""
|
46 |
+
self.model_name = model_name
|
47 |
+
self.two_stems = two_stems
|
48 |
+
|
49 |
+
def separate_vocals(self, audio_file: str, output_dir: str) -> Optional[str]:
|
50 |
+
"""
|
51 |
+
Separates vocals (or other specified stem) from the audio file.
|
52 |
+
|
53 |
+
This method invokes the Demucs model to isolate a specified audio stem (e.g., vocals).
|
54 |
+
The output is saved in WAV format in the specified output directory.
|
55 |
+
|
56 |
+
Parameters
|
57 |
+
----------
|
58 |
+
audio_file : str
|
59 |
+
Path to the input audio file.
|
60 |
+
output_dir : str
|
61 |
+
Directory where the separated files will be saved.
|
62 |
+
|
63 |
+
Returns
|
64 |
+
-------
|
65 |
+
Optional[str]
|
66 |
+
Path to the separated vocal file if successful, or the original audio file path if not.
|
67 |
+
|
68 |
+
Raises
|
69 |
+
------
|
70 |
+
Warning
|
71 |
+
If vocal separation fails or the separated file is not found.
|
72 |
+
|
73 |
+
Examples
|
74 |
+
--------
|
75 |
+
>>> separator = DemucsVocalSeparator()
|
76 |
+
>>> vocal_path = separator.separate_vocals("path/to/audio/file.mp3", "output_dir")
|
77 |
+
Vocal separation successful! Outputs saved in WAV format at 'output_dir' directory.
|
78 |
+
"""
|
79 |
+
demucs_args = [
|
80 |
+
"--two-stems", self.two_stems,
|
81 |
+
"-n", self.model_name,
|
82 |
+
"-o", output_dir,
|
83 |
+
audio_file
|
84 |
+
]
|
85 |
+
|
86 |
+
try:
|
87 |
+
demucs.separate.main(demucs_args)
|
88 |
+
print(f"Vocal separation successful! Outputs saved in WAV format at '{output_dir}' directory.")
|
89 |
+
|
90 |
+
output_path = os.path.join(
|
91 |
+
output_dir, self.model_name,
|
92 |
+
os.path.splitext(os.path.basename(audio_file))[0]
|
93 |
+
)
|
94 |
+
vocal_file = os.path.join(output_path, f"{self.two_stems}.wav")
|
95 |
+
|
96 |
+
if os.path.exists(vocal_file):
|
97 |
+
return vocal_file
|
98 |
+
else:
|
99 |
+
print("Separated vocal file not found. Returning original audio file path.")
|
100 |
+
warnings.warn("Vocal separation was unsuccessful; using the original audio file.", stacklevel=2)
|
101 |
+
return audio_file
|
102 |
+
|
103 |
+
except Exception as e:
|
104 |
+
print(f"An error occurred during vocal separation: {e}")
|
105 |
+
warnings.warn("Vocal separation failed; proceeding with the original audio file.", stacklevel=2)
|
106 |
+
return audio_file
|
107 |
+
|
108 |
+
|
109 |
+
if __name__ == "__main__":
|
110 |
+
file = "example_audio.mp3"
|
111 |
+
output_directory = "separated_outputs"
|
112 |
+
vocal_separator = DemucsVocalSeparator()
|
113 |
+
separated_file_path = vocal_separator.separate_vocals(file, output_directory)
|
114 |
+
print(f"Separated file path: {separated_file_path}")
|
src/audio/error.py
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
import logging
|
4 |
+
import subprocess
|
5 |
+
from typing import Annotated
|
6 |
+
|
7 |
+
# Related third party imports
|
8 |
+
from pyannote.audio import Pipeline
|
9 |
+
|
10 |
+
logging.basicConfig(level=logging.INFO)
|
11 |
+
|
12 |
+
|
13 |
+
class DialogueDetecting:
|
14 |
+
"""
|
15 |
+
Class for detecting dialogue in audio files using speaker diarization.
|
16 |
+
|
17 |
+
This class processes audio files by dividing them into chunks, applying a
|
18 |
+
pre-trained speaker diarization model, and detecting if there are multiple
|
19 |
+
speakers in the audio.
|
20 |
+
|
21 |
+
Parameters
|
22 |
+
----------
|
23 |
+
pipeline_model : str, optional
|
24 |
+
Name of the pre-trained diarization model. Defaults to "pyannote/speaker-diarization".
|
25 |
+
chunk_duration : int, optional
|
26 |
+
Duration of each chunk in seconds. Defaults to 5.
|
27 |
+
sample_rate : int, optional
|
28 |
+
Sampling rate for the processed audio chunks. Defaults to 16000.
|
29 |
+
channels : int, optional
|
30 |
+
Number of audio channels. Defaults to 1.
|
31 |
+
delete_original : bool, optional
|
32 |
+
If True, deletes the original audio file when no dialogue is detected. Defaults to False.
|
33 |
+
skip_if_no_dialogue : bool, optional
|
34 |
+
If True, skips further processing if no dialogue is detected. Defaults to False.
|
35 |
+
temp_dir : str, optional
|
36 |
+
Directory for temporary chunk files. Defaults to ".temp".
|
37 |
+
|
38 |
+
Attributes
|
39 |
+
----------
|
40 |
+
pipeline : Pipeline
|
41 |
+
Instance of the PyAnnote pipeline for speaker diarization.
|
42 |
+
"""
|
43 |
+
|
44 |
+
def __init__(self,
|
45 |
+
pipeline_model: str = "pyannote/speaker-diarization",
|
46 |
+
chunk_duration: int = 5,
|
47 |
+
sample_rate: int = 16000,
|
48 |
+
channels: int = 1,
|
49 |
+
delete_original: bool = False,
|
50 |
+
skip_if_no_dialogue: bool = False,
|
51 |
+
temp_dir: str = ".temp"):
|
52 |
+
self.pipeline_model = pipeline_model
|
53 |
+
self.chunk_duration = chunk_duration
|
54 |
+
self.sample_rate = sample_rate
|
55 |
+
self.channels = channels
|
56 |
+
self.delete_original = delete_original
|
57 |
+
self.skip_if_no_dialogue = skip_if_no_dialogue
|
58 |
+
self.temp_dir = temp_dir
|
59 |
+
self.pipeline = Pipeline.from_pretrained(pipeline_model)
|
60 |
+
|
61 |
+
if not os.path.exists(self.temp_dir):
|
62 |
+
os.makedirs(self.temp_dir)
|
63 |
+
|
64 |
+
@staticmethod
|
65 |
+
def get_audio_duration(audio_file: Annotated[str, "Path to the audio file"]) -> Annotated[
|
66 |
+
float, "Duration of the audio in seconds"]:
|
67 |
+
"""
|
68 |
+
Get the duration of an audio file in seconds.
|
69 |
+
|
70 |
+
Parameters
|
71 |
+
----------
|
72 |
+
audio_file : str
|
73 |
+
Path to the audio file.
|
74 |
+
|
75 |
+
Returns
|
76 |
+
-------
|
77 |
+
float
|
78 |
+
Duration of the audio file in seconds.
|
79 |
+
|
80 |
+
Examples
|
81 |
+
--------
|
82 |
+
>>> DialogueDetecting.get_audio_duration("example.wav")
|
83 |
+
120.5
|
84 |
+
"""
|
85 |
+
result = subprocess.run(
|
86 |
+
["ffprobe", "-v", "error", "-show_entries", "format=duration",
|
87 |
+
"-of", "default=noprint_wrappers=1:nokey=1", audio_file],
|
88 |
+
capture_output=True, text=True, check=True
|
89 |
+
)
|
90 |
+
return float(result.stdout.strip())
|
91 |
+
|
92 |
+
def create_chunk(self, audio_file: str, chunk_file: str, start_time: float, end_time: float):
|
93 |
+
"""
|
94 |
+
Create a chunk of the audio file.
|
95 |
+
|
96 |
+
Parameters
|
97 |
+
----------
|
98 |
+
audio_file : str
|
99 |
+
Path to the original audio file.
|
100 |
+
chunk_file : str
|
101 |
+
Path to save the generated chunk file.
|
102 |
+
start_time : float
|
103 |
+
Start time of the chunk in seconds.
|
104 |
+
end_time : float
|
105 |
+
End time of the chunk in seconds.
|
106 |
+
"""
|
107 |
+
duration = end_time - start_time
|
108 |
+
subprocess.run([
|
109 |
+
"ffmpeg", "-y",
|
110 |
+
"-ss", str(start_time),
|
111 |
+
"-t", str(duration),
|
112 |
+
"-i", audio_file,
|
113 |
+
"-ar", str(self.sample_rate),
|
114 |
+
"-ac", str(self.channels),
|
115 |
+
"-f", "wav",
|
116 |
+
chunk_file
|
117 |
+
], check=True)
|
118 |
+
|
119 |
+
def process_chunk(self, chunk_file: Annotated[str, "Path to the chunk file"]) -> Annotated[
|
120 |
+
set, "Set of detected speaker labels"]:
|
121 |
+
"""
|
122 |
+
Process a single chunk of audio to detect speakers.
|
123 |
+
|
124 |
+
Parameters
|
125 |
+
----------
|
126 |
+
chunk_file : str
|
127 |
+
Path to the chunk file.
|
128 |
+
|
129 |
+
Returns
|
130 |
+
-------
|
131 |
+
set
|
132 |
+
Set of detected speaker labels in the chunk.
|
133 |
+
"""
|
134 |
+
diarization = self.pipeline(chunk_file)
|
135 |
+
speakers_in_chunk = set()
|
136 |
+
for segment, track, label in diarization.itertracks(yield_label=True):
|
137 |
+
speakers_in_chunk.add(label)
|
138 |
+
return speakers_in_chunk
|
139 |
+
|
140 |
+
def process(self, audio_file: Annotated[str, "Path to the input audio file"]) -> Annotated[
|
141 |
+
bool, "True if dialogue detected, False otherwise"]:
|
142 |
+
"""
|
143 |
+
Process the audio file to detect dialogue.
|
144 |
+
|
145 |
+
Parameters
|
146 |
+
----------
|
147 |
+
audio_file : str
|
148 |
+
Path to the audio file.
|
149 |
+
|
150 |
+
Returns
|
151 |
+
-------
|
152 |
+
bool
|
153 |
+
True if at least two speakers are detected, False otherwise.
|
154 |
+
|
155 |
+
Examples
|
156 |
+
--------
|
157 |
+
>>> dialogue_detector = DialogueDetecting()
|
158 |
+
>>> dialogue_detector.process("example.wav")
|
159 |
+
True
|
160 |
+
"""
|
161 |
+
total_duration = self.get_audio_duration(audio_file)
|
162 |
+
num_chunks = int(total_duration // self.chunk_duration) + 1
|
163 |
+
|
164 |
+
speakers_detected = set()
|
165 |
+
chunk_files = []
|
166 |
+
|
167 |
+
try:
|
168 |
+
for i in range(num_chunks):
|
169 |
+
start_time = i * self.chunk_duration
|
170 |
+
end_time = min(float((i + 1) * self.chunk_duration), total_duration)
|
171 |
+
|
172 |
+
if end_time - start_time < 1.0:
|
173 |
+
logging.info("Last chunk is too short to process.")
|
174 |
+
break
|
175 |
+
|
176 |
+
chunk_file = os.path.join(self.temp_dir, f"chunk_{i}.wav")
|
177 |
+
chunk_files.append(chunk_file)
|
178 |
+
logging.info(f"Creating chunk: {chunk_file}")
|
179 |
+
self.create_chunk(audio_file, chunk_file, start_time, end_time)
|
180 |
+
|
181 |
+
logging.info(f"Processing chunk: {chunk_file}")
|
182 |
+
chunk_speakers = self.process_chunk(chunk_file)
|
183 |
+
speakers_detected.update(chunk_speakers)
|
184 |
+
|
185 |
+
if len(speakers_detected) >= 2:
|
186 |
+
logging.info("At least two speakers detected, stopping.")
|
187 |
+
return True
|
188 |
+
|
189 |
+
if len(speakers_detected) < 2:
|
190 |
+
logging.info("No dialogue detected or only one speaker found.")
|
191 |
+
if self.delete_original:
|
192 |
+
logging.info(f"No dialogue found. Deleting original file: {audio_file}")
|
193 |
+
os.remove(audio_file)
|
194 |
+
if self.skip_if_no_dialogue:
|
195 |
+
logging.info("Skipping further processing due to lack of dialogue.")
|
196 |
+
return False
|
197 |
+
|
198 |
+
finally:
|
199 |
+
logging.info("Cleaning up temporary chunk files.")
|
200 |
+
for chunk_file in chunk_files:
|
201 |
+
if os.path.exists(chunk_file):
|
202 |
+
os.remove(chunk_file)
|
203 |
+
|
204 |
+
if os.path.exists(self.temp_dir) and not os.listdir(self.temp_dir):
|
205 |
+
os.rmdir(self.temp_dir)
|
206 |
+
|
207 |
+
return len(speakers_detected) >= 2
|
208 |
+
|
209 |
+
|
210 |
+
if __name__ == "__main__":
|
211 |
+
processor = DialogueDetecting(delete_original=True)
|
212 |
+
audio_path = ".data/example/kafkasya.mp3"
|
213 |
+
process_result = processor.process(audio_path)
|
214 |
+
print("Dialogue detected:", process_result)
|
src/audio/io.py
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
from typing import List, Dict, Annotated
|
4 |
+
|
5 |
+
|
6 |
+
class SpeakerTimestampReader:
|
7 |
+
"""
|
8 |
+
A class to read and parse speaker timestamps from an RTTM file.
|
9 |
+
|
10 |
+
Attributes
|
11 |
+
----------
|
12 |
+
rttm_path : str
|
13 |
+
Path to the RTTM file containing speaker timestamps.
|
14 |
+
|
15 |
+
Methods
|
16 |
+
-------
|
17 |
+
read_speaker_timestamps()
|
18 |
+
Reads the RTTM file and extracts speaker timestamps.
|
19 |
+
|
20 |
+
Parameters
|
21 |
+
----------
|
22 |
+
rttm_path : str
|
23 |
+
Path to the RTTM file containing speaker timestamps.
|
24 |
+
|
25 |
+
Raises
|
26 |
+
------
|
27 |
+
FileNotFoundError
|
28 |
+
If the RTTM file does not exist at the specified path.
|
29 |
+
|
30 |
+
"""
|
31 |
+
|
32 |
+
def __init__(self, rttm_path: str):
|
33 |
+
"""
|
34 |
+
Initializes the SpeakerTimestampReader with the path to an RTTM file.
|
35 |
+
|
36 |
+
Parameters
|
37 |
+
----------
|
38 |
+
rttm_path : str
|
39 |
+
Path to the RTTM file containing speaker timestamps.
|
40 |
+
|
41 |
+
Raises
|
42 |
+
------
|
43 |
+
FileNotFoundError
|
44 |
+
If the RTTM file does not exist at the specified path.
|
45 |
+
"""
|
46 |
+
if not os.path.isfile(rttm_path):
|
47 |
+
raise FileNotFoundError(f"RTTM file not found at: {rttm_path}")
|
48 |
+
self.rttm_path = rttm_path
|
49 |
+
|
50 |
+
def read_speaker_timestamps(self) -> List[List[float]]:
|
51 |
+
"""
|
52 |
+
Reads the RTTM file and extracts speaker timestamps.
|
53 |
+
|
54 |
+
Returns
|
55 |
+
-------
|
56 |
+
List[List[float]]
|
57 |
+
A list where each sublist contains [start_time, end_time, speaker_label].
|
58 |
+
|
59 |
+
Notes
|
60 |
+
-----
|
61 |
+
- The times are converted to milliseconds.
|
62 |
+
- Lines with invalid data are skipped.
|
63 |
+
|
64 |
+
Examples
|
65 |
+
--------
|
66 |
+
>>> reader = SpeakerTimestampReader("path/to/rttm_file.rttm")
|
67 |
+
>>> timestamps = reader.read_speaker_timestamps()
|
68 |
+
Speaker_Timestamps: [[0.0, 2000.0, 1], [2100.0, 4000.0, 2]]
|
69 |
+
"""
|
70 |
+
speaker_ts = []
|
71 |
+
with open(self.rttm_path) as f:
|
72 |
+
lines = f.readlines()
|
73 |
+
for line in lines:
|
74 |
+
line_list = line.strip().split()
|
75 |
+
try:
|
76 |
+
if len(line_list) < 8:
|
77 |
+
print(f"Skipping line due to unexpected format: {line.strip()}")
|
78 |
+
continue
|
79 |
+
|
80 |
+
start_time = float(line_list[3]) * 1000
|
81 |
+
duration = float(line_list[4]) * 1000
|
82 |
+
end_time = start_time + duration
|
83 |
+
|
84 |
+
speaker_label_str = line_list[7]
|
85 |
+
speaker_label = int(speaker_label_str.split("_")[-1])
|
86 |
+
|
87 |
+
speaker_ts.append([start_time, end_time, speaker_label])
|
88 |
+
except (ValueError, IndexError) as e:
|
89 |
+
print(f"Skipping line due to parsing error: {line.strip()} - {e}")
|
90 |
+
continue
|
91 |
+
|
92 |
+
print(f"Speaker_Timestamps: {speaker_ts}")
|
93 |
+
return speaker_ts
|
94 |
+
|
95 |
+
|
96 |
+
class TranscriptWriter:
|
97 |
+
"""
|
98 |
+
A class to write speaker-aware transcripts in plain text or SRT formats.
|
99 |
+
|
100 |
+
Methods
|
101 |
+
-------
|
102 |
+
write_transcript(sentences_speaker_mapping, file_path)
|
103 |
+
Writes the speaker-aware transcript to a text file.
|
104 |
+
write_srt(sentences_speaker_mapping, file_path)
|
105 |
+
Writes the speaker-aware transcript to an SRT file format.
|
106 |
+
"""
|
107 |
+
|
108 |
+
def __init__(self):
|
109 |
+
"""
|
110 |
+
Initializes the TranscriptWriter.
|
111 |
+
"""
|
112 |
+
pass
|
113 |
+
|
114 |
+
@staticmethod
|
115 |
+
def write_transcript(sentences_speaker_mapping: List[Dict], file_path: str):
|
116 |
+
"""
|
117 |
+
Writes the speaker-aware transcript to a text file.
|
118 |
+
|
119 |
+
Parameters
|
120 |
+
----------
|
121 |
+
sentences_speaker_mapping : List[Dict]
|
122 |
+
List of sentences with speaker labels, where each dictionary contains:
|
123 |
+
- "speaker": Speaker label (e.g., Speaker 1, Speaker 2).
|
124 |
+
- "text": Text of the spoken sentence.
|
125 |
+
file_path : str
|
126 |
+
Path to the output text file.
|
127 |
+
|
128 |
+
Examples
|
129 |
+
--------
|
130 |
+
>>> sentences_speaker_map = [{"speaker": "Speaker 1", "text": "Hello."},
|
131 |
+
{"speaker": "Speaker 2", "text": "Hi there."}]
|
132 |
+
>>> TranscriptWriter.write_transcript(sentences_speaker_mapping, "output.txt")
|
133 |
+
"""
|
134 |
+
with open(file_path, "w", encoding="utf-8") as f:
|
135 |
+
previous_speaker = sentences_speaker_mapping[0]["speaker"]
|
136 |
+
f.write(f"{previous_speaker}: ")
|
137 |
+
|
138 |
+
for sentence_dict in sentences_speaker_mapping:
|
139 |
+
speaker = sentence_dict["speaker"]
|
140 |
+
sentence = sentence_dict["text"].strip()
|
141 |
+
|
142 |
+
if speaker != previous_speaker:
|
143 |
+
f.write(f"\n\n{speaker}: ")
|
144 |
+
previous_speaker = speaker
|
145 |
+
|
146 |
+
f.write(sentence + " ")
|
147 |
+
|
148 |
+
@staticmethod
|
149 |
+
def write_srt(sentences_speaker_mapping: List[Dict], file_path: str):
|
150 |
+
"""
|
151 |
+
Writes the speaker-aware transcript to an SRT file format.
|
152 |
+
|
153 |
+
Parameters
|
154 |
+
----------
|
155 |
+
sentences_speaker_mapping : List[Dict]
|
156 |
+
List of sentences with speaker labels and timestamps, where each dictionary contains:
|
157 |
+
- "start_time": Start time of the sentence in milliseconds.
|
158 |
+
- "end_time": End time of the sentence in milliseconds.
|
159 |
+
- "speaker": Speaker label.
|
160 |
+
- "text": Text of the spoken sentence.
|
161 |
+
file_path : str
|
162 |
+
Path to the output SRT file.
|
163 |
+
|
164 |
+
Notes
|
165 |
+
-----
|
166 |
+
The function formats timestamps in the HH:MM:SS,mmm format for SRT.
|
167 |
+
|
168 |
+
Examples
|
169 |
+
--------
|
170 |
+
>>> sentences_speaker_map = [{"start_time": 0, "end_time": 2000,
|
171 |
+
"speaker": "Speaker 1", "text": "Hello."}]
|
172 |
+
>>> TranscriptWriter.write_srt(sentences_speaker_mapping, "output.srt")
|
173 |
+
"""
|
174 |
+
|
175 |
+
def format_timestamp(milliseconds: Annotated[float, "Time in milliseconds"]) -> Annotated[
|
176 |
+
str, "Formatted timestamp in HH:MM:SS,mmm"]:
|
177 |
+
"""
|
178 |
+
Converts a time value in milliseconds to an SRT timestamp format.
|
179 |
+
|
180 |
+
This function takes a time value in milliseconds and formats it into
|
181 |
+
the standard SRT (SubRip Subtitle) timestamp format: `HH:MM:SS,mmm`.
|
182 |
+
|
183 |
+
Parameters
|
184 |
+
----------
|
185 |
+
milliseconds : float
|
186 |
+
Time value in milliseconds to be converted.
|
187 |
+
|
188 |
+
Returns
|
189 |
+
-------
|
190 |
+
str
|
191 |
+
A string representing the time in `HH:MM:SS,mmm` format.
|
192 |
+
|
193 |
+
Raises
|
194 |
+
------
|
195 |
+
ValueError
|
196 |
+
If the input time is negative.
|
197 |
+
|
198 |
+
Examples
|
199 |
+
--------
|
200 |
+
>>> format_timestamp(3723001)
|
201 |
+
'01:02:03,001'
|
202 |
+
>>> format_timestamp(0)
|
203 |
+
'00:00:00,000'
|
204 |
+
>>> format_timestamp(59_999.9)
|
205 |
+
'00:00:59,999'
|
206 |
+
|
207 |
+
Notes
|
208 |
+
-----
|
209 |
+
The function ensures the correct zero-padding for hours, minutes,
|
210 |
+
seconds, and milliseconds to meet the SRT format requirements.
|
211 |
+
"""
|
212 |
+
if milliseconds < 0:
|
213 |
+
raise ValueError("Time in milliseconds cannot be negative.")
|
214 |
+
|
215 |
+
hours = int(milliseconds // 3_600_000)
|
216 |
+
minutes = int((milliseconds % 3_600_000) // 60_000)
|
217 |
+
seconds = int((milliseconds % 60_000) // 1_000)
|
218 |
+
milliseconds = int(milliseconds % 1_000)
|
219 |
+
|
220 |
+
return f"{hours:02d}:{minutes:02d}:{seconds:02d},{milliseconds:03d}"
|
221 |
+
|
222 |
+
with open(file_path, "w", encoding="utf-8") as f:
|
223 |
+
for i, segment in enumerate(sentences_speaker_mapping, start=1):
|
224 |
+
start_time = format_timestamp(segment['start_time'])
|
225 |
+
end_time = format_timestamp(segment['end_time'])
|
226 |
+
speaker = segment['speaker']
|
227 |
+
text = segment['text'].strip().replace('-->', '->')
|
228 |
+
|
229 |
+
f.write(f"{i}\n")
|
230 |
+
f.write(f"{start_time} --> {end_time}\n")
|
231 |
+
f.write(f"{speaker}: {text}\n\n")
|
232 |
+
|
233 |
+
|
234 |
+
if __name__ == "__main__":
|
235 |
+
example_rttm_path = "example.rttm"
|
236 |
+
try:
|
237 |
+
timestamp_reader = SpeakerTimestampReader(example_rttm_path)
|
238 |
+
extracted_speaker_timestamps = timestamp_reader.read_speaker_timestamps()
|
239 |
+
except FileNotFoundError as file_error:
|
240 |
+
print(file_error)
|
241 |
+
|
242 |
+
example_sentences_mapping = [
|
243 |
+
{"speaker": "Speaker 1", "text": "Hello there.", "start_time": 0, "end_time": 2000},
|
244 |
+
{"speaker": "Speaker 2", "text": "How are you?", "start_time": 2100, "end_time": 4000},
|
245 |
+
]
|
246 |
+
transcript_writer = TranscriptWriter()
|
247 |
+
transcript_writer.write_transcript(example_sentences_mapping, "output.txt")
|
248 |
+
transcript_writer.write_srt(example_sentences_mapping, "output.srt")
|
src/audio/metrics.py
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import math
|
3 |
+
from typing import Annotated, List, Dict
|
4 |
+
|
5 |
+
# Related third-party imports
|
6 |
+
import numpy as np
|
7 |
+
|
8 |
+
|
9 |
+
class SilenceStats:
|
10 |
+
"""
|
11 |
+
A class to compute and analyze statistics for silence durations
|
12 |
+
between speech segments.
|
13 |
+
|
14 |
+
This class provides methods to compute common statistical metrics
|
15 |
+
(mean, median, standard deviation, interquartile range) and thresholds
|
16 |
+
based on silence durations.
|
17 |
+
|
18 |
+
Attributes
|
19 |
+
----------
|
20 |
+
silence_durations : List[float]
|
21 |
+
A sorted list of silence durations.
|
22 |
+
|
23 |
+
Methods
|
24 |
+
-------
|
25 |
+
from_segments(segments)
|
26 |
+
Class method to create a SilenceStats instance from speech segments.
|
27 |
+
median()
|
28 |
+
Compute the median silence duration.
|
29 |
+
mean()
|
30 |
+
Compute the mean silence duration.
|
31 |
+
std()
|
32 |
+
Compute the standard deviation of silence durations.
|
33 |
+
iqr()
|
34 |
+
Compute the interquartile range (IQR) of silence durations.
|
35 |
+
threshold_std(factor=0.95)
|
36 |
+
Compute threshold based on standard deviation.
|
37 |
+
threshold_median_iqr(factor=1.5)
|
38 |
+
Compute threshold based on median + IQR.
|
39 |
+
total_silence_above_threshold(threshold)
|
40 |
+
Compute total silence above a given threshold.
|
41 |
+
"""
|
42 |
+
|
43 |
+
def __init__(self, silence_durations: Annotated[List[float], "List of silence durations"]):
|
44 |
+
"""
|
45 |
+
Initialize the SilenceStats class with a list of silence durations.
|
46 |
+
|
47 |
+
Parameters
|
48 |
+
----------
|
49 |
+
silence_durations : List[float]
|
50 |
+
List of silence durations (non-negative values).
|
51 |
+
"""
|
52 |
+
if not all(isinstance(x, (int, float)) and x >= 0 for x in silence_durations):
|
53 |
+
raise ValueError("silence_durations must be a list of non-negative numbers.")
|
54 |
+
self.silence_durations = sorted(silence_durations)
|
55 |
+
|
56 |
+
@classmethod
|
57 |
+
def from_segments(cls, segments: Annotated[List[Dict], "List of speech segments"]) -> "SilenceStats":
|
58 |
+
"""
|
59 |
+
Create a SilenceStats instance from a list of speech segments.
|
60 |
+
|
61 |
+
Parameters
|
62 |
+
----------
|
63 |
+
segments : List[Dict]
|
64 |
+
List of speech segments, where each segment contains 'start_time'
|
65 |
+
and 'end_time' keys.
|
66 |
+
|
67 |
+
Returns
|
68 |
+
-------
|
69 |
+
SilenceStats
|
70 |
+
A SilenceStats instance with computed silence durations.
|
71 |
+
|
72 |
+
Examples
|
73 |
+
--------
|
74 |
+
>>> segment = [{"start_time": 0, "end_time": 5}, {"start_time": 10, "end_time": 15}]
|
75 |
+
>>> stat = SilenceStats.from_segments(segments)
|
76 |
+
>>> stat.silence_durations
|
77 |
+
[5]
|
78 |
+
"""
|
79 |
+
segments_sorted = sorted(segments, key=lambda x: x['start_time'])
|
80 |
+
durations = [
|
81 |
+
segments_sorted[i + 1]['start_time'] - segments_sorted[i]['end_time']
|
82 |
+
for i in range(len(segments_sorted) - 1)
|
83 |
+
if (segments_sorted[i + 1]['start_time'] - segments_sorted[i]['end_time']) > 0
|
84 |
+
]
|
85 |
+
return cls(durations)
|
86 |
+
|
87 |
+
def median(self) -> Annotated[float, "Median of silence durations"]:
|
88 |
+
"""
|
89 |
+
Compute the median silence duration.
|
90 |
+
|
91 |
+
Returns
|
92 |
+
-------
|
93 |
+
float
|
94 |
+
The median of the silence durations.
|
95 |
+
"""
|
96 |
+
n = len(self.silence_durations)
|
97 |
+
if n == 0:
|
98 |
+
return 0.0
|
99 |
+
mid = n // 2
|
100 |
+
if n % 2 == 0:
|
101 |
+
return (self.silence_durations[mid - 1] + self.silence_durations[mid]) / 2
|
102 |
+
return self.silence_durations[mid]
|
103 |
+
|
104 |
+
def mean(self) -> Annotated[float, "Mean of silence durations"]:
|
105 |
+
"""
|
106 |
+
Compute the mean silence duration.
|
107 |
+
|
108 |
+
Returns
|
109 |
+
-------
|
110 |
+
float
|
111 |
+
The mean of the silence durations.
|
112 |
+
"""
|
113 |
+
return sum(self.silence_durations) / len(self.silence_durations) if self.silence_durations else 0.0
|
114 |
+
|
115 |
+
def std(self) -> Annotated[float, "Standard deviation of silence durations"]:
|
116 |
+
"""
|
117 |
+
Compute the standard deviation of silence durations.
|
118 |
+
|
119 |
+
Returns
|
120 |
+
-------
|
121 |
+
float
|
122 |
+
The standard deviation of the silence durations.
|
123 |
+
"""
|
124 |
+
n = len(self.silence_durations)
|
125 |
+
if n == 0:
|
126 |
+
return 0.0
|
127 |
+
mu = self.mean()
|
128 |
+
var = sum((x - mu) ** 2 for x in self.silence_durations) / n
|
129 |
+
return math.sqrt(var)
|
130 |
+
|
131 |
+
def iqr(self) -> Annotated[float, "Interquartile range (IQR) of silence durations"]:
|
132 |
+
"""
|
133 |
+
Compute the Interquartile Range (IQR).
|
134 |
+
|
135 |
+
Returns
|
136 |
+
-------
|
137 |
+
float
|
138 |
+
The IQR of the silence durations.
|
139 |
+
"""
|
140 |
+
if not self.silence_durations:
|
141 |
+
return 0.0
|
142 |
+
q1 = np.percentile(self.silence_durations, 25)
|
143 |
+
q3 = np.percentile(self.silence_durations, 75)
|
144 |
+
return q3 - q1
|
145 |
+
|
146 |
+
def threshold_std(self, factor: Annotated[float, "Scaling factor for std threshold"] = 0.95) -> float:
|
147 |
+
"""
|
148 |
+
Compute the threshold based on standard deviation.
|
149 |
+
|
150 |
+
Parameters
|
151 |
+
----------
|
152 |
+
factor : float, optional
|
153 |
+
A scaling factor for the standard deviation, by default 0.95.
|
154 |
+
|
155 |
+
Returns
|
156 |
+
-------
|
157 |
+
float
|
158 |
+
Threshold based on standard deviation.
|
159 |
+
"""
|
160 |
+
return self.std() * factor
|
161 |
+
|
162 |
+
def threshold_median_iqr(self, factor: Annotated[float, "Scaling factor for IQR"] = 1.5) -> float:
|
163 |
+
"""
|
164 |
+
Compute the threshold based on median and IQR.
|
165 |
+
|
166 |
+
Parameters
|
167 |
+
----------
|
168 |
+
factor : float, optional
|
169 |
+
A scaling factor for the IQR, by default 1.5.
|
170 |
+
|
171 |
+
Returns
|
172 |
+
-------
|
173 |
+
float
|
174 |
+
Threshold based on median and IQR.
|
175 |
+
"""
|
176 |
+
return self.median() + (self.iqr() * factor)
|
177 |
+
|
178 |
+
def total_silence_above_threshold(
|
179 |
+
self, threshold: Annotated[float, "Threshold value for silence"]
|
180 |
+
) -> Annotated[float, "Total silence above the threshold"]:
|
181 |
+
"""
|
182 |
+
Compute the total silence above the given threshold.
|
183 |
+
|
184 |
+
Parameters
|
185 |
+
----------
|
186 |
+
threshold : float
|
187 |
+
The threshold value to compare silence durations.
|
188 |
+
|
189 |
+
Returns
|
190 |
+
-------
|
191 |
+
float
|
192 |
+
Total silence duration above the threshold.
|
193 |
+
"""
|
194 |
+
return sum(s for s in self.silence_durations if s >= threshold)
|
195 |
+
|
196 |
+
|
197 |
+
if __name__ == "__main__":
|
198 |
+
final_ssm = {
|
199 |
+
'ssm': [
|
200 |
+
{'speaker': 'Customer', 'start_time': 8500, 'end_time': 9760, 'text': 'Hey, G-Chance, this is Jennifer. ',
|
201 |
+
'index': 0, 'sentiment': 'Neutral', 'profane': False},
|
202 |
+
{'speaker': 'CSR', 'start_time': 10660, 'end_time': 11560, 'text': 'Yes, hi, Jennifer. ', 'index': 1,
|
203 |
+
'sentiment': 'Neutral', 'profane': False},
|
204 |
+
{'speaker': 'CSR', 'start_time': 11620, 'end_time': 12380, 'text': "Good afternoon, ma'am. ", 'index': 2,
|
205 |
+
'sentiment': 'Neutral', 'profane': False},
|
206 |
+
{'speaker': 'CSR', 'start_time': 83880, 'end_time': 85460, 'text': 'Okay. ', 'index': 24,
|
207 |
+
'sentiment': 'Neutral', 'profane': False},
|
208 |
+
{'speaker': 'CSR', 'start_time': 85500, 'end_time': 85620, 'text': 'Yeah. ', 'index': 25,
|
209 |
+
'sentiment': 'Neutral', 'profane': False},
|
210 |
+
{'speaker': 'CSR', 'start_time': 86400, 'end_time': 90320,
|
211 |
+
'text': "So I'll be sending this shipping documents right after this call. ", 'index': 26,
|
212 |
+
'sentiment': 'Neutral', 'profane': False},
|
213 |
+
{'speaker': 'CSR', 'start_time': 90400, 'end_time': 91160, 'text': 'Thank you so much. ', 'index': 27,
|
214 |
+
'sentiment': 'Neutral', 'profane': False},
|
215 |
+
{'speaker': 'Customer', 'start_time': 92060, 'end_time': 92680, 'text': 'Okay, thank you. ', 'index': 28,
|
216 |
+
'sentiment': 'Neutral', 'profane': False},
|
217 |
+
{'speaker': 'Customer', 'start_time': 93880, 'end_time': 98220, 'text': 'All right, bye-bye. ', 'index': 29,
|
218 |
+
'sentiment': 'Neutral', 'profane': False}
|
219 |
+
],
|
220 |
+
'summary': 'Gabby from Transplace AP Team called Jennifer to request copies of a carrier invoice, bill of '
|
221 |
+
'lading, and proof of delivery, and Jennifer provided her email for Gabby to send the shipping '
|
222 |
+
'documents.',
|
223 |
+
'conflict': False,
|
224 |
+
'topic': 'Invoice and Shipping Documents Request'
|
225 |
+
}
|
226 |
+
|
227 |
+
stats = SilenceStats.from_segments(final_ssm['ssm'])
|
228 |
+
|
229 |
+
print("Mean:", stats.mean())
|
230 |
+
print("Median:", stats.median())
|
231 |
+
print("Std Dev:", stats.std())
|
232 |
+
print("IQR:", stats.iqr())
|
233 |
+
|
234 |
+
t_std = stats.threshold_std(factor=0.97)
|
235 |
+
t_median_iqr = stats.threshold_median_iqr(factor=1.49)
|
236 |
+
print("Threshold (std-based):", t_std)
|
237 |
+
print("Threshold (median+IQR):", t_median_iqr)
|
238 |
+
|
239 |
+
print("Total silence (std-based):", stats.total_silence_above_threshold(t_std))
|
240 |
+
print("Total silence (median+IQR-based):", stats.total_silence_above_threshold(t_median_iqr))
|
241 |
+
final_ssm["silence"] = t_std
|
242 |
+
print(final_ssm)
|
src/audio/preprocessing.py
ADDED
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
from typing import Annotated
|
4 |
+
|
5 |
+
# Related third-party imports
|
6 |
+
import librosa
|
7 |
+
import soundfile as sf
|
8 |
+
from librosa.feature import rms
|
9 |
+
from omegaconf import OmegaConf
|
10 |
+
from noisereduce import reduce_noise
|
11 |
+
from MPSENet import MPSENet
|
12 |
+
|
13 |
+
# Local imports
|
14 |
+
from src.utils.utils import Logger
|
15 |
+
|
16 |
+
|
17 |
+
class Denoiser:
|
18 |
+
"""
|
19 |
+
A class to handle audio denoising using librosa and noisereduce.
|
20 |
+
|
21 |
+
This class provides methods to load noisy audio, apply denoising, and
|
22 |
+
save the cleaned output to disk.
|
23 |
+
|
24 |
+
Parameters
|
25 |
+
----------
|
26 |
+
config_path : str
|
27 |
+
Path to the configuration file that specifies runtime settings.
|
28 |
+
output_dir : str, optional
|
29 |
+
Directory to save cleaned audio files. Defaults to ".temp".
|
30 |
+
|
31 |
+
Attributes
|
32 |
+
----------
|
33 |
+
config : omegaconf.DictConfig
|
34 |
+
Loaded configuration data.
|
35 |
+
output_dir : str
|
36 |
+
Directory to save cleaned audio files.
|
37 |
+
logger : Logger
|
38 |
+
Logger instance for recording messages.
|
39 |
+
"""
|
40 |
+
|
41 |
+
def __init__(self, config_path: Annotated[str, "Path to the config file"],
|
42 |
+
output_dir: Annotated[str, "Default directory to save cleaned audio files"] = ".temp") -> None:
|
43 |
+
"""
|
44 |
+
Initialize the Denoiser class.
|
45 |
+
|
46 |
+
Parameters
|
47 |
+
----------
|
48 |
+
config_path : str
|
49 |
+
Path to the configuration file that specifies runtime settings.
|
50 |
+
output_dir : str, optional
|
51 |
+
Default directory to save cleaned audio files. Defaults to ".temp".
|
52 |
+
"""
|
53 |
+
self.config = OmegaConf.load(config_path)
|
54 |
+
self.output_dir = output_dir
|
55 |
+
os.makedirs(self.output_dir, exist_ok=True)
|
56 |
+
self.logger = Logger(name="DenoiserLogger")
|
57 |
+
|
58 |
+
def denoise_audio(
|
59 |
+
self,
|
60 |
+
input_path: Annotated[str, "Path to the noisy audio file"],
|
61 |
+
output_dir: Annotated[str, "Directory to save the cleaned audio file"],
|
62 |
+
noise_threshold: Annotated[float, "Noise threshold value to decide if denoising is needed"],
|
63 |
+
print_output: Annotated[bool, "Whether to log the process to console"] = False,
|
64 |
+
) -> str:
|
65 |
+
"""
|
66 |
+
Denoise an audio file using noisereduce and librosa.
|
67 |
+
|
68 |
+
Parameters
|
69 |
+
----------
|
70 |
+
input_path : str
|
71 |
+
Path to the noisy input audio file.
|
72 |
+
output_dir : str
|
73 |
+
Directory to save the cleaned audio file.
|
74 |
+
noise_threshold : float
|
75 |
+
Noise threshold value to decide if denoising is needed.
|
76 |
+
print_output : bool, optional
|
77 |
+
Whether to log the process to the console. Defaults to False.
|
78 |
+
|
79 |
+
Returns
|
80 |
+
-------
|
81 |
+
str
|
82 |
+
Path to the saved audio file if denoising is performed, otherwise the original audio file path.
|
83 |
+
|
84 |
+
Examples
|
85 |
+
--------
|
86 |
+
>>> denoise = Denoiser("config.yaml")
|
87 |
+
>>> input_file = "noisy_audio.wav"
|
88 |
+
>>> output_directory = "cleaned_audio"
|
89 |
+
>>> noise_thresh = 0.02
|
90 |
+
>>> result = denoiser.denoise_audio(input_file, output_directory, noise_thresh)
|
91 |
+
>>> print(result)
|
92 |
+
cleaned_audio/denoised.wav
|
93 |
+
"""
|
94 |
+
self.logger.log(f"Loading: {input_path}", print_output=print_output)
|
95 |
+
|
96 |
+
noisy_waveform, sr = librosa.load(input_path, sr=None)
|
97 |
+
|
98 |
+
noise_level = rms(y=noisy_waveform).mean()
|
99 |
+
self.logger.log(f"Calculated noise level: {noise_level}", print_output=print_output)
|
100 |
+
|
101 |
+
if noise_level < noise_threshold:
|
102 |
+
self.logger.log("Noise level is below the threshold. Skipping denoising.", print_output=print_output)
|
103 |
+
return input_path
|
104 |
+
|
105 |
+
self.logger.log("Denoising process started...", print_output=print_output)
|
106 |
+
|
107 |
+
cleaned_waveform = reduce_noise(y=noisy_waveform, sr=sr)
|
108 |
+
|
109 |
+
output_path = os.path.join(output_dir, "denoised.wav")
|
110 |
+
|
111 |
+
os.makedirs(output_dir, exist_ok=True)
|
112 |
+
|
113 |
+
sf.write(output_path, cleaned_waveform, sr)
|
114 |
+
|
115 |
+
self.logger.log(f"Denoising completed! Cleaned file: {output_path}", print_output=print_output)
|
116 |
+
|
117 |
+
return output_path
|
118 |
+
|
119 |
+
|
120 |
+
class SpeechEnhancement:
|
121 |
+
"""
|
122 |
+
A class for speech enhancement using the MPSENet model.
|
123 |
+
|
124 |
+
This class provides methods to load audio, apply enhancement using a
|
125 |
+
pre-trained MPSENet model, and save the enhanced output.
|
126 |
+
|
127 |
+
Parameters
|
128 |
+
----------
|
129 |
+
config_path : str
|
130 |
+
Path to the configuration file specifying runtime settings.
|
131 |
+
output_dir : str, optional
|
132 |
+
Directory to save enhanced audio files. Defaults to ".temp".
|
133 |
+
|
134 |
+
Attributes
|
135 |
+
----------
|
136 |
+
config : omegaconf.DictConfig
|
137 |
+
Loaded configuration data.
|
138 |
+
output_dir : str
|
139 |
+
Directory to save enhanced audio files.
|
140 |
+
model_name : str
|
141 |
+
Name of the pre-trained model.
|
142 |
+
device : str
|
143 |
+
Device to run the model (e.g., "cpu" or "cuda").
|
144 |
+
model : MPSENet
|
145 |
+
Pre-trained MPSENet model instance.
|
146 |
+
"""
|
147 |
+
|
148 |
+
def __init__(
|
149 |
+
self,
|
150 |
+
config_path: Annotated[str, "Path to the config file"],
|
151 |
+
output_dir: Annotated[str, "Default directory to save enhanced audio files"] = ".temp"
|
152 |
+
) -> None:
|
153 |
+
"""
|
154 |
+
Initialize the SpeechEnhancement class.
|
155 |
+
|
156 |
+
Parameters
|
157 |
+
----------
|
158 |
+
config_path : str
|
159 |
+
Path to the configuration file specifying runtime settings.
|
160 |
+
output_dir : str, optional
|
161 |
+
Directory to save enhanced audio files. Defaults to ".temp".
|
162 |
+
"""
|
163 |
+
self.config = OmegaConf.load(config_path)
|
164 |
+
self.output_dir = output_dir
|
165 |
+
os.makedirs(self.output_dir, exist_ok=True)
|
166 |
+
|
167 |
+
self.model_name = self.config.models.mpsenet.model_name
|
168 |
+
self.device = self.config.runtime.device
|
169 |
+
|
170 |
+
self.model = MPSENet.from_pretrained(self.model_name).to(self.device)
|
171 |
+
|
172 |
+
def enhance_audio(
|
173 |
+
self,
|
174 |
+
input_path: Annotated[str, "Path to the original audio file"],
|
175 |
+
output_path: Annotated[str, "Path to save the enhanced audio file"],
|
176 |
+
noise_threshold: Annotated[float, "Noise threshold value to decide if enhancement is needed"],
|
177 |
+
verbose: Annotated[bool, "Whether to log additional info to console"] = False,
|
178 |
+
) -> str:
|
179 |
+
"""
|
180 |
+
Enhance an audio file using the MPSENet model.
|
181 |
+
|
182 |
+
Parameters
|
183 |
+
----------
|
184 |
+
input_path : str
|
185 |
+
Path to the original input audio file.
|
186 |
+
output_path : str
|
187 |
+
Path to save the enhanced audio file.
|
188 |
+
noise_threshold : float
|
189 |
+
Noise threshold value to decide if enhancement is needed.
|
190 |
+
verbose : bool, optional
|
191 |
+
Whether to log additional info to the console. Defaults to False.
|
192 |
+
|
193 |
+
Returns
|
194 |
+
-------
|
195 |
+
str
|
196 |
+
Path to the enhanced audio file if enhancement is performed, otherwise the original file path.
|
197 |
+
|
198 |
+
Examples
|
199 |
+
--------
|
200 |
+
>>> enhancer = SpeechEnhancement("config.yaml")
|
201 |
+
>>> input_file = "raw_audio.wav"
|
202 |
+
>>> output_file = "enhanced_audio.wav"
|
203 |
+
>>> noise_thresh = 0.03
|
204 |
+
>>> result = enhancer.enhance_audio(input_file, output_file, noise_thresh)
|
205 |
+
>>> print(result)
|
206 |
+
enhanced_audio.wav
|
207 |
+
"""
|
208 |
+
raw_waveform, sr_raw = librosa.load(input_path, sr=None)
|
209 |
+
noise_level = rms(y=raw_waveform).mean()
|
210 |
+
|
211 |
+
if verbose:
|
212 |
+
print(f"[SpeechEnhancement] Detected noise level: {noise_level:.6f}")
|
213 |
+
|
214 |
+
if noise_level < noise_threshold:
|
215 |
+
if verbose:
|
216 |
+
print(f"[SpeechEnhancement] Noise level < {noise_threshold} → enhancement skipped.")
|
217 |
+
return input_path
|
218 |
+
|
219 |
+
sr_model = self.model.h.sampling_rate
|
220 |
+
waveform, sr = librosa.load(input_path, sr=sr_model)
|
221 |
+
|
222 |
+
if verbose:
|
223 |
+
print(f"[SpeechEnhancement] Enhancement with MPSENet started using model: {self.model_name}")
|
224 |
+
|
225 |
+
enhanced_waveform, sr_out, _ = self.model(waveform)
|
226 |
+
|
227 |
+
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
228 |
+
sf.write(output_path, enhanced_waveform, sr_out)
|
229 |
+
|
230 |
+
if verbose:
|
231 |
+
print(f"[SpeechEnhancement] Enhancement complete. Saved to: {output_path}")
|
232 |
+
|
233 |
+
return output_path
|
234 |
+
|
235 |
+
|
236 |
+
if __name__ == "__main__":
|
237 |
+
|
238 |
+
test_config_path = "config/config.yaml"
|
239 |
+
noisy_audio_file = ".data/example/noisy/LookOncetoHearTargetSpeechHearingwithNoisyExamples.mp3"
|
240 |
+
temp_dir = ".temp"
|
241 |
+
|
242 |
+
denoiser = Denoiser(config_path=test_config_path, output_dir=temp_dir)
|
243 |
+
denoised_path = denoiser.denoise_audio(
|
244 |
+
input_path=noisy_audio_file,
|
245 |
+
output_dir=temp_dir,
|
246 |
+
noise_threshold=0.005,
|
247 |
+
print_output=True
|
248 |
+
)
|
249 |
+
if denoised_path == noisy_audio_file:
|
250 |
+
print("Denoising skipped due to low noise level.")
|
251 |
+
else:
|
252 |
+
print(f"Denoising completed! Cleaned file saved at: {denoised_path}")
|
253 |
+
|
254 |
+
speech_enhancer = SpeechEnhancement(config_path=test_config_path, output_dir=temp_dir)
|
255 |
+
enhanced_audio_path = os.path.join(temp_dir, "enhanced_audio.wav")
|
256 |
+
|
257 |
+
result_path = speech_enhancer.enhance_audio(
|
258 |
+
input_path=denoised_path,
|
259 |
+
output_path=enhanced_audio_path,
|
260 |
+
noise_threshold=0.005,
|
261 |
+
verbose=True
|
262 |
+
)
|
263 |
+
|
264 |
+
if result_path == denoised_path:
|
265 |
+
print("Enhancement skipped due to low noise level.")
|
266 |
+
else:
|
267 |
+
print(f"Speech enhancement completed! Enhanced file saved at: {result_path}")
|
src/audio/processing.py
ADDED
@@ -0,0 +1,614 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os
|
3 |
+
import re
|
4 |
+
import json
|
5 |
+
from io import TextIOWrapper
|
6 |
+
from typing import Annotated, Optional, Tuple, List, Dict
|
7 |
+
|
8 |
+
# Related third party imports
|
9 |
+
import torch
|
10 |
+
import faster_whisper
|
11 |
+
from pydub import AudioSegment
|
12 |
+
from deepmultilingualpunctuation import PunctuationModel
|
13 |
+
|
14 |
+
# Local imports
|
15 |
+
from src.audio.utils import TokenizerUtils
|
16 |
+
|
17 |
+
|
18 |
+
class AudioProcessor:
|
19 |
+
"""
|
20 |
+
A class to handle various audio processing tasks, such as conversion,
|
21 |
+
trimming, merging, and audio transformations.
|
22 |
+
|
23 |
+
Parameters
|
24 |
+
----------
|
25 |
+
audio_path : str
|
26 |
+
Path to the audio file to process.
|
27 |
+
temp_dir : str, optional
|
28 |
+
Directory for storing temporary files. Defaults to ".temp".
|
29 |
+
|
30 |
+
Attributes
|
31 |
+
----------
|
32 |
+
audio_path : str
|
33 |
+
Path to the input audio file.
|
34 |
+
temp_dir : str
|
35 |
+
Path to the temporary directory for processed files.
|
36 |
+
mono_audio_path : Optional[str]
|
37 |
+
Path to the mono audio file after conversion.
|
38 |
+
|
39 |
+
Methods
|
40 |
+
-------
|
41 |
+
convert_to_mono()
|
42 |
+
Converts the audio file to mono.
|
43 |
+
get_duration()
|
44 |
+
Gets the duration of the audio file in seconds.
|
45 |
+
change_format(new_format)
|
46 |
+
Converts the audio file to a new format.
|
47 |
+
trim_audio(start_time, end_time)
|
48 |
+
Trims the audio file to the specified time range.
|
49 |
+
adjust_volume(change_in_db)
|
50 |
+
Adjusts the volume of the audio file.
|
51 |
+
get_channels()
|
52 |
+
Gets the number of audio channels.
|
53 |
+
fade_in_out(fade_in_duration, fade_out_duration)
|
54 |
+
Applies fade-in and fade-out effects to the audio.
|
55 |
+
merge_audio(other_audio_path)
|
56 |
+
Merges the current audio with another audio file.
|
57 |
+
split_audio(chunk_duration)
|
58 |
+
Splits the audio file into chunks of a specified duration.
|
59 |
+
create_manifest(manifest_path)
|
60 |
+
Creates a manifest file containing metadata about the audio.
|
61 |
+
"""
|
62 |
+
|
63 |
+
def __init__(
|
64 |
+
self,
|
65 |
+
audio_path: Annotated[str, "Path to the audio file"],
|
66 |
+
temp_dir: Annotated[str, "Directory for temporary processed files"] = ".temp"
|
67 |
+
) -> None:
|
68 |
+
if not isinstance(audio_path, str):
|
69 |
+
raise TypeError("Expected 'audio_path' to be a string.")
|
70 |
+
if not isinstance(temp_dir, str):
|
71 |
+
raise TypeError("Expected 'temp_dir' to be a string.")
|
72 |
+
|
73 |
+
self.audio_path = audio_path
|
74 |
+
self.temp_dir = temp_dir
|
75 |
+
self.mono_audio_path = None
|
76 |
+
os.makedirs(temp_dir, exist_ok=True)
|
77 |
+
|
78 |
+
def convert_to_mono(self) -> Annotated[str, "Path to the mono audio file"]:
|
79 |
+
"""
|
80 |
+
Convert the audio file to mono.
|
81 |
+
|
82 |
+
Returns
|
83 |
+
-------
|
84 |
+
str
|
85 |
+
Path to the mono audio file.
|
86 |
+
|
87 |
+
Examples
|
88 |
+
--------
|
89 |
+
>>> processor = AudioProcessor("example.wav")
|
90 |
+
>>> mono_path = processor.convert_to_mono()
|
91 |
+
>>> isinstance(mono_path, str)
|
92 |
+
True
|
93 |
+
"""
|
94 |
+
sound = AudioSegment.from_file(self.audio_path)
|
95 |
+
mono_sound = sound.set_channels(1)
|
96 |
+
self.mono_audio_path = os.path.join(self.temp_dir, "mono_file.wav")
|
97 |
+
mono_sound.export(self.mono_audio_path, format="wav")
|
98 |
+
return self.mono_audio_path
|
99 |
+
|
100 |
+
def get_duration(self) -> Annotated[float, "Audio duration in seconds"]:
|
101 |
+
"""
|
102 |
+
Get the duration of the audio file.
|
103 |
+
|
104 |
+
Returns
|
105 |
+
-------
|
106 |
+
float
|
107 |
+
Duration of the audio in seconds.
|
108 |
+
|
109 |
+
Examples
|
110 |
+
--------
|
111 |
+
>>> processor = AudioProcessor("example.wav")
|
112 |
+
>>> duration = processor.get_duration()
|
113 |
+
>>> isinstance(duration, float)
|
114 |
+
True
|
115 |
+
"""
|
116 |
+
sound = AudioSegment.from_file(self.audio_path)
|
117 |
+
return len(sound) / 1000.0
|
118 |
+
|
119 |
+
def change_format(
|
120 |
+
self, new_format: Annotated[str, "New audio format"]
|
121 |
+
) -> Annotated[str, "Path to converted audio file"]:
|
122 |
+
"""
|
123 |
+
Convert the audio file to a new format.
|
124 |
+
|
125 |
+
Parameters
|
126 |
+
----------
|
127 |
+
new_format : str
|
128 |
+
Desired format for the output audio file.
|
129 |
+
|
130 |
+
Returns
|
131 |
+
-------
|
132 |
+
str
|
133 |
+
Path to the converted audio file.
|
134 |
+
|
135 |
+
Examples
|
136 |
+
--------
|
137 |
+
>>> processor = AudioProcessor("example.wav")
|
138 |
+
>>> converted_path = processor.change_format("mp3")
|
139 |
+
>>> isinstance(converted_path, str)
|
140 |
+
True
|
141 |
+
"""
|
142 |
+
if not isinstance(new_format, str):
|
143 |
+
raise TypeError("Expected 'new_format' to be a string.")
|
144 |
+
|
145 |
+
sound = AudioSegment.from_file(self.audio_path)
|
146 |
+
output_path = os.path.join(self.temp_dir, f"converted_file.{new_format}")
|
147 |
+
sound.export(output_path, format=new_format)
|
148 |
+
return output_path
|
149 |
+
|
150 |
+
def trim_audio(
|
151 |
+
self, start_time: Annotated[float, "Start time in seconds"],
|
152 |
+
end_time: Annotated[float, "End time in seconds"]
|
153 |
+
) -> Annotated[str, "Path to trimmed audio file"]:
|
154 |
+
"""
|
155 |
+
Trim the audio file to the specified duration.
|
156 |
+
|
157 |
+
Parameters
|
158 |
+
----------
|
159 |
+
start_time : float
|
160 |
+
Start time in seconds.
|
161 |
+
end_time : float
|
162 |
+
End time in seconds.
|
163 |
+
|
164 |
+
Returns
|
165 |
+
-------
|
166 |
+
str
|
167 |
+
Path to the trimmed audio file.
|
168 |
+
|
169 |
+
Examples
|
170 |
+
--------
|
171 |
+
>>> processor = AudioProcessor("example.wav")
|
172 |
+
>>> trimmed_path = processor.trim_audio(0.0, 10.0)
|
173 |
+
>>> isinstance(trimmed_path, str)
|
174 |
+
True
|
175 |
+
"""
|
176 |
+
if not isinstance(start_time, (int, float)):
|
177 |
+
raise TypeError("Expected 'start_time' to be a float or int.")
|
178 |
+
if not isinstance(end_time, (int, float)):
|
179 |
+
raise TypeError("Expected 'end_time' to be a float or int.")
|
180 |
+
|
181 |
+
sound = AudioSegment.from_file(self.audio_path)
|
182 |
+
trimmed_audio = sound[start_time * 1000:end_time * 1000]
|
183 |
+
trimmed_audio_path = os.path.join(self.temp_dir, "trimmed_file.wav")
|
184 |
+
trimmed_audio.export(trimmed_audio_path, format="wav")
|
185 |
+
return trimmed_audio_path
|
186 |
+
|
187 |
+
def adjust_volume(
|
188 |
+
self, change_in_db: Annotated[float, "Volume change in dB"]
|
189 |
+
) -> Annotated[str, "Path to volume-adjusted audio file"]:
|
190 |
+
"""
|
191 |
+
Adjust the volume of the audio file.
|
192 |
+
|
193 |
+
Parameters
|
194 |
+
----------
|
195 |
+
change_in_db : float
|
196 |
+
Volume change in decibels.
|
197 |
+
|
198 |
+
Returns
|
199 |
+
-------
|
200 |
+
str
|
201 |
+
Path to the volume-adjusted audio file.
|
202 |
+
|
203 |
+
Examples
|
204 |
+
--------
|
205 |
+
>>> processor = AudioProcessor("example.wav")
|
206 |
+
>>> adjusted_path = processor.adjust_volume(5.0)
|
207 |
+
>>> isinstance(adjusted_path, str)
|
208 |
+
True
|
209 |
+
"""
|
210 |
+
if not isinstance(change_in_db, (int, float)):
|
211 |
+
raise TypeError("Expected 'change_in_db' to be a float or int.")
|
212 |
+
|
213 |
+
sound = AudioSegment.from_file(self.audio_path)
|
214 |
+
adjusted_audio = sound + change_in_db
|
215 |
+
adjusted_audio_path = os.path.join(self.temp_dir, "adjusted_volume.wav")
|
216 |
+
adjusted_audio.export(adjusted_audio_path, format="wav")
|
217 |
+
return adjusted_audio_path
|
218 |
+
|
219 |
+
def get_channels(self) -> Annotated[int, "Number of channels"]:
|
220 |
+
"""
|
221 |
+
Get the number of audio channels.
|
222 |
+
|
223 |
+
Returns
|
224 |
+
-------
|
225 |
+
int
|
226 |
+
Number of audio channels.
|
227 |
+
|
228 |
+
Examples
|
229 |
+
--------
|
230 |
+
>>> processor = AudioProcessor("example.wav")
|
231 |
+
>>> channels = processor.get_channels()
|
232 |
+
>>> isinstance(channels, int)
|
233 |
+
True
|
234 |
+
"""
|
235 |
+
sound = AudioSegment.from_file(self.audio_path)
|
236 |
+
return sound.channels
|
237 |
+
|
238 |
+
def fade_in_out(
|
239 |
+
self, fade_in_duration: Annotated[float, "Fade-in duration in seconds"],
|
240 |
+
fade_out_duration: Annotated[float, "Fade-out duration in seconds"]
|
241 |
+
) -> Annotated[str, "Path to faded audio file"]:
|
242 |
+
"""
|
243 |
+
Apply fade-in and fade-out effects to the audio file.
|
244 |
+
|
245 |
+
Parameters
|
246 |
+
----------
|
247 |
+
fade_in_duration : float
|
248 |
+
Duration of the fade-in effect in seconds.
|
249 |
+
fade_out_duration : float
|
250 |
+
Duration of the fade-out effect in seconds.
|
251 |
+
|
252 |
+
Returns
|
253 |
+
-------
|
254 |
+
str
|
255 |
+
Path to the faded audio file.
|
256 |
+
|
257 |
+
Examples
|
258 |
+
--------
|
259 |
+
>>> processor = AudioProcessor("example.wav")
|
260 |
+
>>> faded_path = processor.fade_in_out(1.0, 2.0)
|
261 |
+
>>> isinstance(faded_path, str)
|
262 |
+
True
|
263 |
+
"""
|
264 |
+
if not isinstance(fade_in_duration, (int, float)):
|
265 |
+
raise TypeError("Expected 'fade_in_duration' to be a float or int.")
|
266 |
+
if not isinstance(fade_out_duration, (int, float)):
|
267 |
+
raise TypeError("Expected 'fade_out_duration' to be a float or int.")
|
268 |
+
|
269 |
+
sound = AudioSegment.from_file(self.audio_path)
|
270 |
+
faded_audio = sound.fade_in(fade_in_duration * 1000).fade_out(fade_out_duration * 1000)
|
271 |
+
faded_audio_path = os.path.join(self.temp_dir, "faded_audio.wav")
|
272 |
+
faded_audio.export(faded_audio_path, format="wav")
|
273 |
+
return faded_audio_path
|
274 |
+
|
275 |
+
def merge_audio(
|
276 |
+
self, other_audio_path: Annotated[str, "Path to other audio file"]
|
277 |
+
) -> Annotated[str, "Path to merged audio file"]:
|
278 |
+
"""
|
279 |
+
Merge the current audio file with another audio file.
|
280 |
+
|
281 |
+
Parameters
|
282 |
+
----------
|
283 |
+
other_audio_path : str
|
284 |
+
Path to the other audio file.
|
285 |
+
|
286 |
+
Returns
|
287 |
+
-------
|
288 |
+
str
|
289 |
+
Path to the merged audio file.
|
290 |
+
|
291 |
+
Examples
|
292 |
+
--------
|
293 |
+
>>> processor = AudioProcessor("example.wav")
|
294 |
+
>>> merged_path = processor.merge_audio("other_example.wav")
|
295 |
+
>>> isinstance(merged_path, str)
|
296 |
+
True
|
297 |
+
"""
|
298 |
+
if not isinstance(other_audio_path, str):
|
299 |
+
raise TypeError("Expected 'other_audio_path' to be a string.")
|
300 |
+
|
301 |
+
sound1 = AudioSegment.from_file(self.audio_path)
|
302 |
+
sound2 = AudioSegment.from_file(other_audio_path)
|
303 |
+
merged_audio = sound1 + sound2
|
304 |
+
merged_audio_path = os.path.join(self.temp_dir, "merged_audio.wav")
|
305 |
+
merged_audio.export(merged_audio_path, format="wav")
|
306 |
+
return merged_audio_path
|
307 |
+
|
308 |
+
def split_audio(
|
309 |
+
self, chunk_duration: Annotated[float, "Chunk duration in seconds"]
|
310 |
+
) -> Annotated[List[str], "Paths to audio chunks"]:
|
311 |
+
"""
|
312 |
+
Split the audio file into chunks of the specified duration.
|
313 |
+
|
314 |
+
Parameters
|
315 |
+
----------
|
316 |
+
chunk_duration : float
|
317 |
+
Duration of each chunk in seconds.
|
318 |
+
|
319 |
+
Returns
|
320 |
+
-------
|
321 |
+
List[str]
|
322 |
+
Paths to the generated audio chunks.
|
323 |
+
|
324 |
+
Examples
|
325 |
+
--------
|
326 |
+
>>> processor = AudioProcessor("example.wav")
|
327 |
+
>>> chunks = processor.split_audio(10.0)
|
328 |
+
>>> isinstance(chunks, list)
|
329 |
+
True
|
330 |
+
"""
|
331 |
+
if not isinstance(chunk_duration, (int, float)):
|
332 |
+
raise TypeError("Expected 'chunk_duration' to be a float or int.")
|
333 |
+
|
334 |
+
sound = AudioSegment.from_file(self.audio_path)
|
335 |
+
chunk_paths = []
|
336 |
+
|
337 |
+
for i in range(0, len(sound), int(chunk_duration * 1000)):
|
338 |
+
chunk = sound[i:i + int(chunk_duration * 1000)]
|
339 |
+
chunk_path = os.path.join(self.temp_dir, f"chunk_{i // 1000}.wav")
|
340 |
+
chunk.export(chunk_path, format="wav")
|
341 |
+
chunk_paths.append(chunk_path)
|
342 |
+
|
343 |
+
return chunk_paths
|
344 |
+
|
345 |
+
def create_manifest(
|
346 |
+
self,
|
347 |
+
manifest_path: Annotated[str, "Manifest file path"]
|
348 |
+
) -> None:
|
349 |
+
"""
|
350 |
+
Create a manifest file containing metadata about the audio file.
|
351 |
+
|
352 |
+
Parameters
|
353 |
+
----------
|
354 |
+
manifest_path : str
|
355 |
+
Path to the manifest file.
|
356 |
+
|
357 |
+
Examples
|
358 |
+
--------
|
359 |
+
>>> processor = AudioProcessor("example.wav")
|
360 |
+
>>> processor.create_manifest("manifest.json")
|
361 |
+
"""
|
362 |
+
duration = self.get_duration()
|
363 |
+
manifest_entry = {
|
364 |
+
"audio_filepath": self.audio_path,
|
365 |
+
"offset": 0,
|
366 |
+
"duration": duration,
|
367 |
+
"label": "infer",
|
368 |
+
"text": "-",
|
369 |
+
"rttm_filepath": None,
|
370 |
+
"uem_filepath": None
|
371 |
+
}
|
372 |
+
with open(manifest_path, 'w', encoding='utf-8') as f: # type: TextIOWrapper
|
373 |
+
json.dump(manifest_entry, f)
|
374 |
+
|
375 |
+
|
376 |
+
class Transcriber:
|
377 |
+
"""
|
378 |
+
A class for transcribing audio files using a pre-trained Whisper model.
|
379 |
+
|
380 |
+
Parameters
|
381 |
+
----------
|
382 |
+
model_name : str, optional
|
383 |
+
Name of the model to load. Defaults to 'large-v3'.
|
384 |
+
device : str, optional
|
385 |
+
Device to use for model inference ('cpu' or 'cuda'). Defaults to 'cpu'.
|
386 |
+
compute_type : str, optional
|
387 |
+
Data type for model computation ('int8', 'float16', etc.). Defaults to 'int8'.
|
388 |
+
|
389 |
+
Attributes
|
390 |
+
----------
|
391 |
+
model : faster_whisper.WhisperModel
|
392 |
+
Loaded Whisper model for transcription.
|
393 |
+
device : str
|
394 |
+
Device used for inference.
|
395 |
+
|
396 |
+
Methods
|
397 |
+
-------
|
398 |
+
transcribe(audio_path, language=None, suppress_numerals=False)
|
399 |
+
Transcribes the audio file into text.
|
400 |
+
"""
|
401 |
+
|
402 |
+
def __init__(
|
403 |
+
self,
|
404 |
+
model_name: Annotated[str, "Name of the model to load"] = 'large-v3',
|
405 |
+
device: Annotated[str, "Device to use for model inference"] = 'cpu',
|
406 |
+
compute_type: Annotated[str, "Data type for model computation, e.g., 'int8' or 'float16'"] = 'int8'
|
407 |
+
) -> None:
|
408 |
+
if not isinstance(model_name, str):
|
409 |
+
raise TypeError("Expected 'model_name' to be of type str")
|
410 |
+
if not isinstance(device, str):
|
411 |
+
raise TypeError("Expected 'device' to be of type str")
|
412 |
+
if not isinstance(compute_type, str):
|
413 |
+
raise TypeError("Expected 'compute_type' to be of type str")
|
414 |
+
|
415 |
+
self.device = device
|
416 |
+
self.model = faster_whisper.WhisperModel(
|
417 |
+
model_name, device=device, compute_type=compute_type
|
418 |
+
)
|
419 |
+
|
420 |
+
def transcribe(
|
421 |
+
self,
|
422 |
+
audio_path: Annotated[str, "Path to the audio file to transcribe"],
|
423 |
+
language: Annotated[Optional[str], "Language code for transcription, e.g., 'en' for English"] = None,
|
424 |
+
suppress_numerals: Annotated[bool, "Whether to suppress numerals in the transcription"] = False
|
425 |
+
) -> Annotated[Tuple[str, dict], "Transcription text and additional information"]:
|
426 |
+
"""
|
427 |
+
Transcribe an audio file into text.
|
428 |
+
|
429 |
+
Parameters
|
430 |
+
----------
|
431 |
+
audio_path : str
|
432 |
+
Path to the audio file.
|
433 |
+
language : str, optional
|
434 |
+
Language code for transcription (e.g., 'en' for English).
|
435 |
+
suppress_numerals : bool, optional
|
436 |
+
Whether to suppress numerals in the transcription. Defaults to False.
|
437 |
+
|
438 |
+
Returns
|
439 |
+
-------
|
440 |
+
Tuple[str, dict]
|
441 |
+
The transcribed text and additional transcription metadata.
|
442 |
+
|
443 |
+
Examples
|
444 |
+
--------
|
445 |
+
>>> transcriber = Transcriber()
|
446 |
+
>>> text, information = transcriber.transcribe("example.wav")
|
447 |
+
>>> isinstance(text, str)
|
448 |
+
True
|
449 |
+
>>> isinstance(info, dict)
|
450 |
+
True
|
451 |
+
"""
|
452 |
+
if not isinstance(audio_path, str):
|
453 |
+
raise TypeError("Expected 'audio_path' to be of type str")
|
454 |
+
if language is not None and not isinstance(language, str):
|
455 |
+
raise TypeError("Expected 'language' to be of type str if provided")
|
456 |
+
if not isinstance(suppress_numerals, bool):
|
457 |
+
raise TypeError("Expected 'suppress_numerals' to be of type bool")
|
458 |
+
|
459 |
+
audio_waveform = faster_whisper.decode_audio(audio_path)
|
460 |
+
suppress_tokens = [-1]
|
461 |
+
if suppress_numerals:
|
462 |
+
suppress_tokens = TokenizerUtils.find_numeral_symbol_tokens(
|
463 |
+
self.model.hf_tokenizer
|
464 |
+
)
|
465 |
+
|
466 |
+
transcript_segments, info = self.model.transcribe(
|
467 |
+
audio_waveform,
|
468 |
+
language=language,
|
469 |
+
suppress_tokens=suppress_tokens,
|
470 |
+
without_timestamps=True,
|
471 |
+
vad_filter=True,
|
472 |
+
log_progress=True,
|
473 |
+
)
|
474 |
+
|
475 |
+
transcript = ''.join(segment.text for segment in transcript_segments)
|
476 |
+
info = vars(info)
|
477 |
+
|
478 |
+
if self.device == 'cuda':
|
479 |
+
del self.model
|
480 |
+
torch.cuda.empty_cache()
|
481 |
+
|
482 |
+
print(transcript, info)
|
483 |
+
|
484 |
+
return transcript, info
|
485 |
+
|
486 |
+
|
487 |
+
class PunctuationRestorer:
|
488 |
+
"""
|
489 |
+
A class for restoring punctuation in transcribed text.
|
490 |
+
|
491 |
+
Parameters
|
492 |
+
----------
|
493 |
+
language : str, optional
|
494 |
+
Language for punctuation restoration. Defaults to 'en'.
|
495 |
+
|
496 |
+
Attributes
|
497 |
+
----------
|
498 |
+
language : str
|
499 |
+
Language used for punctuation restoration.
|
500 |
+
punct_model : PunctuationModel
|
501 |
+
Model for predicting punctuation.
|
502 |
+
supported_languages : List[str]
|
503 |
+
List of languages supported by the model.
|
504 |
+
|
505 |
+
Methods
|
506 |
+
-------
|
507 |
+
restore_punctuation(word_speaker_mapping)
|
508 |
+
Restores punctuation in the provided text based on word mappings.
|
509 |
+
"""
|
510 |
+
|
511 |
+
def __init__(self, language: Annotated[str, "Language for punctuation restoration"] = 'en') -> None:
|
512 |
+
self.language = language
|
513 |
+
self.punct_model = PunctuationModel(model="kredor/punctuate-all")
|
514 |
+
self.supported_languages = [
|
515 |
+
"en", "fr", "de", "es", "it", "nl", "pt", "bg", "pl", "cs", "sk", "sl",
|
516 |
+
]
|
517 |
+
|
518 |
+
def restore_punctuation(
|
519 |
+
self, word_speaker_mapping: Annotated[List[Dict], "List of word-speaker mappings"]
|
520 |
+
) -> Annotated[List[Dict], "Word mappings with restored punctuation"]:
|
521 |
+
"""
|
522 |
+
Restore punctuation for transcribed text.
|
523 |
+
|
524 |
+
Parameters
|
525 |
+
----------
|
526 |
+
word_speaker_mapping : List[Dict]
|
527 |
+
List of dictionaries containing word and speaker mappings.
|
528 |
+
|
529 |
+
Returns
|
530 |
+
-------
|
531 |
+
List[Dict]
|
532 |
+
Updated list with punctuation restored.
|
533 |
+
|
534 |
+
Examples
|
535 |
+
--------
|
536 |
+
>>> restorer = PunctuationRestorer()
|
537 |
+
>>> mapping = [{"text": "hello"}, {"text": "world"}]
|
538 |
+
>>> result = restorer.restore_punctuation(mapping)
|
539 |
+
>>> isinstance(result, list)
|
540 |
+
True
|
541 |
+
>>> "text" in result[0]
|
542 |
+
True
|
543 |
+
"""
|
544 |
+
if self.language not in self.supported_languages:
|
545 |
+
print(f"Punctuation restoration is not available for {self.language} language.")
|
546 |
+
return word_speaker_mapping
|
547 |
+
|
548 |
+
words_list = [word_dict["text"] for word_dict in word_speaker_mapping]
|
549 |
+
labeled_words = self.punct_model.predict(words_list)
|
550 |
+
|
551 |
+
ending_puncts = ".?!"
|
552 |
+
model_puncts = ".,;:!?"
|
553 |
+
is_acronym = lambda x: re.fullmatch(r"\b(?:[a-zA-Z]\.){2,}", x)
|
554 |
+
|
555 |
+
for word_dict, labeled_tuple in zip(word_speaker_mapping, labeled_words):
|
556 |
+
word = word_dict["text"]
|
557 |
+
if (
|
558 |
+
word
|
559 |
+
and labeled_tuple[1] in ending_puncts
|
560 |
+
and (word[-1] not in model_puncts or is_acronym(word))
|
561 |
+
):
|
562 |
+
word += labeled_tuple[1]
|
563 |
+
word = word.rstrip(".") if word.endswith("..") else word
|
564 |
+
word_dict["text"] = word
|
565 |
+
|
566 |
+
return word_speaker_mapping
|
567 |
+
|
568 |
+
|
569 |
+
if __name__ == "__main__":
|
570 |
+
sample_audio_path = "sample_audio.wav"
|
571 |
+
audio_processor_instance = AudioProcessor(sample_audio_path)
|
572 |
+
|
573 |
+
mono_audio_path = audio_processor_instance.convert_to_mono()
|
574 |
+
print(f"Mono audio file saved at: {mono_audio_path}")
|
575 |
+
|
576 |
+
audio_duration = audio_processor_instance.get_duration()
|
577 |
+
print(f"Audio duration: {audio_duration} seconds")
|
578 |
+
|
579 |
+
converted_audio_path = audio_processor_instance.change_format("mp3")
|
580 |
+
print(f"Converted audio file saved at: {converted_audio_path}")
|
581 |
+
|
582 |
+
audio_path_trimmed = audio_processor_instance.trim_audio(0.0, 10.0)
|
583 |
+
print(f"Trimmed audio file saved at: {audio_path_trimmed}")
|
584 |
+
|
585 |
+
volume_adjusted_audio_path = audio_processor_instance.adjust_volume(5.0)
|
586 |
+
print(f"Volume adjusted audio file saved at: {volume_adjusted_audio_path}")
|
587 |
+
|
588 |
+
additional_audio_path = "additional_audio.wav"
|
589 |
+
merged_audio_output_path = audio_processor_instance.merge_audio(additional_audio_path)
|
590 |
+
print(f"Merged audio file saved at: {merged_audio_output_path}")
|
591 |
+
|
592 |
+
audio_chunk_paths = audio_processor_instance.split_audio(10.0)
|
593 |
+
print(f"Audio chunks saved at: {audio_chunk_paths}")
|
594 |
+
|
595 |
+
output_manifest_path = "output_manifest.json"
|
596 |
+
audio_processor_instance.create_manifest(output_manifest_path)
|
597 |
+
print(f"Manifest file saved at: {output_manifest_path}")
|
598 |
+
|
599 |
+
transcriber_instance = Transcriber()
|
600 |
+
transcribed_text_output, transcription_metadata = transcriber_instance.transcribe(sample_audio_path)
|
601 |
+
print(f"Transcribed Text: {transcribed_text_output}")
|
602 |
+
print(f"Transcription Info: {transcription_metadata}")
|
603 |
+
|
604 |
+
word_mapping_example = [
|
605 |
+
{"text": "hello"},
|
606 |
+
{"text": "world"},
|
607 |
+
{"text": "this"},
|
608 |
+
{"text": "is"},
|
609 |
+
{"text": "a"},
|
610 |
+
{"text": "test"}
|
611 |
+
]
|
612 |
+
punctuation_restorer_instance = PunctuationRestorer()
|
613 |
+
punctuation_restored_mapping = punctuation_restorer_instance.restore_punctuation(word_mapping_example)
|
614 |
+
print(f"Restored Mapping: {punctuation_restored_mapping}")
|
src/audio/utils.py
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import warnings
|
3 |
+
from typing import List, Dict, Union
|
4 |
+
|
5 |
+
|
6 |
+
class TokenizerUtils:
|
7 |
+
"""
|
8 |
+
Utility class for handling token-related operations, particularly for identifying tokens
|
9 |
+
that contain numerals or specific symbols.
|
10 |
+
|
11 |
+
This class includes an __init__ method for completeness, but it does not perform any
|
12 |
+
initialization since the class is intended to be used as a static utility class.
|
13 |
+
|
14 |
+
Methods
|
15 |
+
-------
|
16 |
+
find_numeral_symbol_tokens(tokenizer)
|
17 |
+
Returns a list of token IDs that include numerals or symbols like '%', '$', or '£'.
|
18 |
+
"""
|
19 |
+
|
20 |
+
def __init__(self):
|
21 |
+
"""Initialize the TokenizerUtils class. This method is present for completeness."""
|
22 |
+
pass
|
23 |
+
|
24 |
+
@staticmethod
|
25 |
+
def find_numeral_symbol_tokens(tokenizer) -> List[int]:
|
26 |
+
"""
|
27 |
+
Identifies tokens that contain numerals or certain symbols in the tokenizer vocabulary.
|
28 |
+
|
29 |
+
Parameters
|
30 |
+
----------
|
31 |
+
tokenizer : Any
|
32 |
+
Tokenizer object with a 'get_vocab' method, typically from Hugging Face's tokenizer library.
|
33 |
+
|
34 |
+
Returns
|
35 |
+
-------
|
36 |
+
List[int]
|
37 |
+
List of token IDs for tokens that contain numerals or symbols.
|
38 |
+
|
39 |
+
Examples
|
40 |
+
--------
|
41 |
+
>>> TokenizerUtils.find_numeral_symbol_tokens(tokenizer)
|
42 |
+
[-1, 123, 456, 789]
|
43 |
+
"""
|
44 |
+
numeral_symbol_tokens = [-1]
|
45 |
+
for token, token_id in tokenizer.get_vocab().items():
|
46 |
+
if any(c in "0123456789%$£" for c in token):
|
47 |
+
numeral_symbol_tokens.append(token_id)
|
48 |
+
return numeral_symbol_tokens
|
49 |
+
|
50 |
+
|
51 |
+
class Formatter:
|
52 |
+
"""
|
53 |
+
A utility class for formatting audio-related data, such as sentence-speaker mappings.
|
54 |
+
|
55 |
+
Methods
|
56 |
+
-------
|
57 |
+
add_indices_to_ssm(ssm: List[Dict], reference_length: int = None) -> List[Dict]:
|
58 |
+
Adds an index key to each item in the SSM list and checks for length mismatches with a reference.
|
59 |
+
format_ssm_as_dialogue(
|
60 |
+
ssm: List[Dict],
|
61 |
+
print_output: bool = False,
|
62 |
+
return_dict: bool = False
|
63 |
+
) -> Union[str, Dict[str, List[str]]]:
|
64 |
+
Formats sentence-speaker mappings into a readable dialogue format and optionally prints it or returns a
|
65 |
+
dictionary grouped by speakers.
|
66 |
+
"""
|
67 |
+
|
68 |
+
@staticmethod
|
69 |
+
def add_indices_to_ssm(ssm: List[Dict], reference_length: int = None) -> List[Dict]:
|
70 |
+
"""
|
71 |
+
Adds an index key to each item in the SSM list and optionally checks for length mismatches with a reference
|
72 |
+
length.
|
73 |
+
|
74 |
+
Parameters
|
75 |
+
----------
|
76 |
+
ssm : List[Dict]
|
77 |
+
The final SSM data.
|
78 |
+
reference_length : int, optional
|
79 |
+
A reference length to compare the SSM length against, default is None.
|
80 |
+
|
81 |
+
Returns
|
82 |
+
-------
|
83 |
+
List[Dict]
|
84 |
+
The SSM data with added index keys and any necessary adjustments.
|
85 |
+
"""
|
86 |
+
if reference_length is not None and len(ssm) != reference_length:
|
87 |
+
warnings.warn(
|
88 |
+
f"Mismatch: SSM Length = {len(ssm)}, Reference Length = {reference_length}. "
|
89 |
+
f"Adjusting to match lengths...",
|
90 |
+
UserWarning,
|
91 |
+
)
|
92 |
+
|
93 |
+
for idx, item in enumerate(ssm):
|
94 |
+
item["index"] = idx
|
95 |
+
|
96 |
+
if reference_length is not None:
|
97 |
+
if len(ssm) > reference_length:
|
98 |
+
ssm = ssm[:reference_length]
|
99 |
+
elif len(ssm) < reference_length:
|
100 |
+
for i in range(len(ssm), reference_length):
|
101 |
+
ssm.append({
|
102 |
+
"index": i,
|
103 |
+
"speaker": "Unknown",
|
104 |
+
"start_time": None,
|
105 |
+
"end_time": None,
|
106 |
+
"text": "[Placeholder]"
|
107 |
+
})
|
108 |
+
|
109 |
+
return ssm
|
110 |
+
|
111 |
+
@staticmethod
|
112 |
+
def format_ssm_as_dialogue(
|
113 |
+
ssm: List[Dict],
|
114 |
+
print_output: bool = False,
|
115 |
+
return_dict: bool = False
|
116 |
+
) -> Union[str, Dict[str, List[str]]]:
|
117 |
+
"""
|
118 |
+
Formats the sentence-speaker mapping (ssm) as a dialogue and optionally prints the result or returns it as a
|
119 |
+
dictionary grouped by speakers.
|
120 |
+
|
121 |
+
Parameters
|
122 |
+
----------
|
123 |
+
ssm : List[Dict]
|
124 |
+
List of sentences with speaker labels.
|
125 |
+
print_output : bool, optional
|
126 |
+
Whether to print the formatted dialogue, default is False.
|
127 |
+
return_dict : bool, optional
|
128 |
+
Whether to return the response as a dictionary grouped by speakers, default is False.
|
129 |
+
|
130 |
+
Returns
|
131 |
+
-------
|
132 |
+
Union[str, Dict[str, List[str]]]
|
133 |
+
If `return_dict` is True, returns a dictionary with speakers as keys and lists of their sentences as values.
|
134 |
+
Otherwise, returns the formatted dialogue string.
|
135 |
+
"""
|
136 |
+
dialogue_dict: Dict[str, List[str]] = {}
|
137 |
+
|
138 |
+
for sentence in ssm:
|
139 |
+
speaker = sentence['speaker']
|
140 |
+
text = sentence['text'].strip()
|
141 |
+
|
142 |
+
if speaker in dialogue_dict:
|
143 |
+
dialogue_dict[speaker].append(text)
|
144 |
+
else:
|
145 |
+
dialogue_dict[speaker] = [text]
|
146 |
+
|
147 |
+
if print_output:
|
148 |
+
print("Formatted Dialogue:")
|
149 |
+
for speaker, texts in dialogue_dict.items():
|
150 |
+
for text in texts:
|
151 |
+
print(f"{speaker}: {text}")
|
152 |
+
print()
|
153 |
+
|
154 |
+
if return_dict:
|
155 |
+
return dialogue_dict
|
156 |
+
|
157 |
+
formatted_dialogue = "\n\n".join(
|
158 |
+
[f"{speaker}: {text}" for speaker, texts in dialogue_dict.items() for text in texts]
|
159 |
+
)
|
160 |
+
return formatted_dialogue
|
161 |
+
|
162 |
+
|
163 |
+
if __name__ == "__main__":
|
164 |
+
# noinspection PyMissingOrEmptyDocstring
|
165 |
+
class DummyTokenizer:
|
166 |
+
@staticmethod
|
167 |
+
def get_vocab():
|
168 |
+
return {
|
169 |
+
"hello": 1,
|
170 |
+
"world": 2,
|
171 |
+
"100%": 3,
|
172 |
+
"$value": 4,
|
173 |
+
"item_123": 5,
|
174 |
+
"£price": 6
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
dummy_tokenizer = DummyTokenizer()
|
179 |
+
numeral_tokens = TokenizerUtils.find_numeral_symbol_tokens(dummy_tokenizer)
|
180 |
+
print(f"Numeral and symbol tokens: {numeral_tokens}")
|
181 |
+
|
182 |
+
speaker_sentence_mapping = [
|
183 |
+
{"speaker": "Speaker 1", "text": "Hello, how are you?"},
|
184 |
+
{"speaker": "Speaker 2", "text": "I'm fine, thank you! And you?"},
|
185 |
+
{"speaker": "Speaker 1", "text": "I'm doing great, thanks for asking."}
|
186 |
+
]
|
187 |
+
|
188 |
+
formatted_dialogue_str = Formatter.format_ssm_as_dialogue(speaker_sentence_mapping, print_output=True)
|
189 |
+
print(f"Formatted Dialogue:\n{formatted_dialogue_str}")
|
src/db/__init__.py
ADDED
File without changes
|
src/db/manager.py
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import sqlite3
|
3 |
+
from typing import Annotated, List, Tuple, Optional
|
4 |
+
|
5 |
+
|
6 |
+
class Database:
|
7 |
+
"""
|
8 |
+
A class to interact with an SQLite database.
|
9 |
+
|
10 |
+
This class provides methods to fetch data, insert data, and handle specific
|
11 |
+
tasks like fetching or inserting topic IDs in a database.
|
12 |
+
|
13 |
+
Parameters
|
14 |
+
----------
|
15 |
+
db_path : str
|
16 |
+
The path to the SQLite database file.
|
17 |
+
|
18 |
+
Attributes
|
19 |
+
----------
|
20 |
+
db_path : str
|
21 |
+
The path to the SQLite database file.
|
22 |
+
"""
|
23 |
+
|
24 |
+
def __init__(self, db_path: Annotated[str, "Path to the SQLite database"]):
|
25 |
+
"""
|
26 |
+
Initializes the Database class with the provided database path.
|
27 |
+
|
28 |
+
Parameters
|
29 |
+
----------
|
30 |
+
db_path : str
|
31 |
+
The path to the SQLite database file.
|
32 |
+
"""
|
33 |
+
self.db_path = db_path
|
34 |
+
|
35 |
+
def fetch(
|
36 |
+
self,
|
37 |
+
sql_file_path: Annotated[str, "Path to the SQL file"]
|
38 |
+
) -> Annotated[List[Tuple], "Results fetched from the query"]:
|
39 |
+
"""
|
40 |
+
Executes a SELECT query from an SQL file and fetches the results.
|
41 |
+
|
42 |
+
Parameters
|
43 |
+
----------
|
44 |
+
sql_file_path : str
|
45 |
+
Path to the SQL file containing the SELECT query.
|
46 |
+
|
47 |
+
Returns
|
48 |
+
-------
|
49 |
+
List[Tuple]
|
50 |
+
A list of tuples representing rows returned by the query.
|
51 |
+
|
52 |
+
Examples
|
53 |
+
--------
|
54 |
+
>>> db = Database("example.db")
|
55 |
+
>>> result = db.fetch("select_query.sql")
|
56 |
+
>>> print(results)
|
57 |
+
[(1, 'data1'), (2, 'data2')]
|
58 |
+
"""
|
59 |
+
with open(sql_file_path, encoding='utf-8') as f:
|
60 |
+
query = f.read()
|
61 |
+
|
62 |
+
conn = sqlite3.connect(self.db_path)
|
63 |
+
cursor = conn.cursor()
|
64 |
+
cursor.execute(query)
|
65 |
+
results = cursor.fetchall()
|
66 |
+
conn.close()
|
67 |
+
|
68 |
+
return results
|
69 |
+
|
70 |
+
def insert(
|
71 |
+
self,
|
72 |
+
sql_file_path: Annotated[str, "Path to the SQL file"],
|
73 |
+
params: Optional[Annotated[Tuple, "Query parameters"]] = None
|
74 |
+
) -> Annotated[int, "ID of the last inserted row"]:
|
75 |
+
"""
|
76 |
+
Executes an INSERT query from an SQL file and returns the last row ID.
|
77 |
+
|
78 |
+
Parameters
|
79 |
+
----------
|
80 |
+
sql_file_path : str
|
81 |
+
Path to the SQL file containing the INSERT query.
|
82 |
+
params : tuple, optional
|
83 |
+
Parameters for the query. Defaults to None.
|
84 |
+
|
85 |
+
Returns
|
86 |
+
-------
|
87 |
+
int
|
88 |
+
The ID of the last inserted row.
|
89 |
+
|
90 |
+
Examples
|
91 |
+
--------
|
92 |
+
>>> db = Database("example.db")
|
93 |
+
>>> last_id_ = db.insert("insert_query.sql", ("value1", "value2"))
|
94 |
+
>>> print(last_id)
|
95 |
+
3
|
96 |
+
"""
|
97 |
+
with open(sql_file_path, encoding='utf-8') as f:
|
98 |
+
query = f.read()
|
99 |
+
|
100 |
+
conn = sqlite3.connect(self.db_path)
|
101 |
+
cursor = conn.cursor()
|
102 |
+
if params is not None:
|
103 |
+
cursor.execute(query, params)
|
104 |
+
else:
|
105 |
+
cursor.execute(query)
|
106 |
+
conn.commit()
|
107 |
+
last_id = cursor.lastrowid
|
108 |
+
conn.close()
|
109 |
+
return last_id
|
110 |
+
|
111 |
+
def get_or_insert_topic_id(
|
112 |
+
self,
|
113 |
+
detected_topic: Annotated[str, "Topic to detect or insert"],
|
114 |
+
topics: Annotated[List[Tuple], "Existing topics with IDs"],
|
115 |
+
db_topic_insert_path: Annotated[str, "Path to the SQL file for inserting topics"]
|
116 |
+
) -> Annotated[int, "Topic ID"]:
|
117 |
+
"""
|
118 |
+
Fetches an existing topic ID or inserts a new one and returns its ID.
|
119 |
+
|
120 |
+
Parameters
|
121 |
+
----------
|
122 |
+
detected_topic : str
|
123 |
+
The topic to be detected or inserted.
|
124 |
+
topics : List[Tuple[int, str]]
|
125 |
+
A list of existing topics as (id, name) tuples.
|
126 |
+
db_topic_insert_path : str
|
127 |
+
Path to the SQL file for inserting a new topic.
|
128 |
+
|
129 |
+
Returns
|
130 |
+
-------
|
131 |
+
int
|
132 |
+
The ID of the detected or newly inserted topic.
|
133 |
+
|
134 |
+
Examples
|
135 |
+
--------
|
136 |
+
>>> db = Database("example.db")
|
137 |
+
>>> topics_ = [(1, 'Python'), (2, 'SQL')]
|
138 |
+
>>> topic_id_ = db.get_or_insert_topic_id("AI", topics, "insert_topic.sql")
|
139 |
+
>>> print(topic_id)
|
140 |
+
3
|
141 |
+
"""
|
142 |
+
detected_topic_lower = detected_topic.lower()
|
143 |
+
topic_map = {t[1].lower(): t[0] for t in topics}
|
144 |
+
|
145 |
+
if detected_topic_lower in topic_map:
|
146 |
+
return topic_map[detected_topic_lower]
|
147 |
+
else:
|
148 |
+
topic_id = self.insert(db_topic_insert_path, (detected_topic,))
|
149 |
+
return topic_id
|
src/db/sql/AudioPropertiesInsert.sql
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
INSERT INTO File (Name,
|
2 |
+
TopicID,
|
3 |
+
Extension,
|
4 |
+
Path,
|
5 |
+
Rate,
|
6 |
+
MinFreq,
|
7 |
+
MaxFreq,
|
8 |
+
BitDepth,
|
9 |
+
Channels,
|
10 |
+
Duration,
|
11 |
+
RMSLoudness,
|
12 |
+
ZeroCrossingRate,
|
13 |
+
SpectralCentroid,
|
14 |
+
EQ_20_250_Hz,
|
15 |
+
EQ_250_2000_Hz,
|
16 |
+
EQ_2000_6000_Hz,
|
17 |
+
EQ_6000_20000_Hz,
|
18 |
+
MFCC_1,
|
19 |
+
MFCC_2,
|
20 |
+
MFCC_3,
|
21 |
+
MFCC_4,
|
22 |
+
MFCC_5,
|
23 |
+
MFCC_6,
|
24 |
+
MFCC_7,
|
25 |
+
MFCC_8,
|
26 |
+
MFCC_9,
|
27 |
+
MFCC_10,
|
28 |
+
MFCC_11,
|
29 |
+
MFCC_12,
|
30 |
+
MFCC_13,
|
31 |
+
Summary,
|
32 |
+
Conflict,
|
33 |
+
Silence)
|
34 |
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
src/db/sql/Schema.sql
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
CREATE TABLE Topic
|
2 |
+
(
|
3 |
+
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
4 |
+
Name TEXT NOT NULL UNIQUE CHECK (length(Name) <= 500)
|
5 |
+
);
|
6 |
+
|
7 |
+
INSERT INTO Topic (Name)
|
8 |
+
VALUES ('Unknown');
|
9 |
+
|
10 |
+
CREATE TABLE File
|
11 |
+
(
|
12 |
+
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
13 |
+
Name TEXT NOT NULL,
|
14 |
+
TopicID INTEGER,
|
15 |
+
Extension TEXT,
|
16 |
+
Path TEXT,
|
17 |
+
Rate INTEGER,
|
18 |
+
MinFreq REAL,
|
19 |
+
MaxFreq REAL,
|
20 |
+
BitDepth INTEGER,
|
21 |
+
Channels INTEGER,
|
22 |
+
Duration REAL,
|
23 |
+
RMSLoudness REAL,
|
24 |
+
ZeroCrossingRate REAL,
|
25 |
+
SpectralCentroid REAL,
|
26 |
+
EQ_20_250_Hz REAL,
|
27 |
+
EQ_250_2000_Hz REAL,
|
28 |
+
EQ_2000_6000_Hz REAL,
|
29 |
+
EQ_6000_20000_Hz REAL,
|
30 |
+
MFCC_1 REAL,
|
31 |
+
MFCC_2 REAL,
|
32 |
+
MFCC_3 REAL,
|
33 |
+
MFCC_4 REAL,
|
34 |
+
MFCC_5 REAL,
|
35 |
+
MFCC_6 REAL,
|
36 |
+
MFCC_7 REAL,
|
37 |
+
MFCC_8 REAL,
|
38 |
+
MFCC_9 REAL,
|
39 |
+
MFCC_10 REAL,
|
40 |
+
MFCC_11 REAL,
|
41 |
+
MFCC_12 REAL,
|
42 |
+
MFCC_13 REAL,
|
43 |
+
Summary TEXT NOT NULL,
|
44 |
+
Conflict INTEGER NOT NULL CHECK (Conflict IN (0, 1)),
|
45 |
+
Silence REAL NOT NULL,
|
46 |
+
|
47 |
+
FOREIGN KEY (TopicID) REFERENCES Topic (ID)
|
48 |
+
);
|
49 |
+
|
50 |
+
CREATE TABLE Utterance
|
51 |
+
(
|
52 |
+
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
53 |
+
FileID INTEGER NOT NULL,
|
54 |
+
Speaker TEXT CHECK (Speaker IN ('Customer', 'CSR')) NOT NULL,
|
55 |
+
Sequence INTEGER NOT NULL,
|
56 |
+
StartTime REAL NOT NULL,
|
57 |
+
EndTime REAL NOT NULL,
|
58 |
+
Content TEXT NOT NULL,
|
59 |
+
Sentiment TEXT CHECK (Sentiment IN ('Neutral', 'Positive', 'Negative')) NOT NULL,
|
60 |
+
Profane INTEGER NOT NULL CHECK (Profane IN (0, 1)),
|
61 |
+
FOREIGN KEY (FileID) REFERENCES File (ID)
|
62 |
+
);
|
src/db/sql/TopicFetch.sql
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SELECT ID, Name
|
2 |
+
FROM Topic;
|