Jabberjay 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jabberjay-0.0.3/.github/workflows/python-package.yml +40 -0
- jabberjay-0.0.3/.github/workflows/python-publish.yml +39 -0
- jabberjay-0.0.3/.github/workflows/ruff.yml +8 -0
- jabberjay-0.0.3/.gitignore +17 -0
- jabberjay-0.0.3/.pre-commit-config.yaml +7 -0
- jabberjay-0.0.3/LICENSE +21 -0
- jabberjay-0.0.3/PKG-INFO +86 -0
- jabberjay-0.0.3/README.md +56 -0
- jabberjay-0.0.3/examples/example.py +109 -0
- jabberjay-0.0.3/pyproject.toml +53 -0
- jabberjay-0.0.3/requirements-dev.txt +3 -0
- jabberjay-0.0.3/requirements.txt +10 -0
- jabberjay-0.0.3/res/bonafide/bonafide.flac +0 -0
- jabberjay-0.0.3/res/spoof/spoof.flac +0 -0
- jabberjay-0.0.3/src/Jabberjay/Models/Classical/feature_extraction.py +31 -0
- jabberjay-0.0.3/src/Jabberjay/Models/Classical/run.py +21 -0
- jabberjay-0.0.3/src/Jabberjay/Models/RawNet2/model.py +398 -0
- jabberjay-0.0.3/src/Jabberjay/Models/RawNet2/model_config_RawNet.yaml +21 -0
- jabberjay-0.0.3/src/Jabberjay/Models/RawNet2/run.py +35 -0
- jabberjay-0.0.3/src/Jabberjay/Models/Tranformer/AST/run.py +13 -0
- jabberjay-0.0.3/src/Jabberjay/Models/Tranformer/VIT/ConstantQ/run.py +21 -0
- jabberjay-0.0.3/src/Jabberjay/Models/Tranformer/VIT/MFCC/run.py +20 -0
- jabberjay-0.0.3/src/Jabberjay/Models/Tranformer/VIT/MelSpectrogram/run.py +21 -0
- jabberjay-0.0.3/src/Jabberjay/Models/Tranformer/VIT/utility.py +19 -0
- jabberjay-0.0.3/src/Jabberjay/Utilities/enum_handler.py +38 -0
- jabberjay-0.0.3/src/Jabberjay/Utilities/hugging_face.py +5 -0
- jabberjay-0.0.3/src/Jabberjay/jabberjay.py +166 -0
- jabberjay-0.0.3/tests/test_jabberjay.py +6 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
|
3
|
+
|
|
4
|
+
name: Python package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "main" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "main" ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
python-version: [ "3.10", "3.11" ]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v3
|
|
23
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
+
uses: actions/setup-python@v3
|
|
25
|
+
with:
|
|
26
|
+
python-version: ${{ matrix.python-version }}
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip
|
|
30
|
+
python -m pip install flake8 pytest
|
|
31
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
32
|
+
- name: Lint with flake8
|
|
33
|
+
run: |
|
|
34
|
+
# stop the build if there are Python syntax errors or undefined names
|
|
35
|
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
36
|
+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
37
|
+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
38
|
+
- name: Test with pytest
|
|
39
|
+
run: |
|
|
40
|
+
pytest
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# This workflow will upload a Python Package using Twine when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
deploy:
|
|
20
|
+
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v3
|
|
25
|
+
- name: Set up Python
|
|
26
|
+
uses: actions/setup-python@v3
|
|
27
|
+
with:
|
|
28
|
+
python-version: '3.x'
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: |
|
|
31
|
+
python -m pip install --upgrade pip
|
|
32
|
+
pip install build
|
|
33
|
+
- name: Build package
|
|
34
|
+
run: python -m build
|
|
35
|
+
- name: Publish package
|
|
36
|
+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
|
|
37
|
+
with:
|
|
38
|
+
user: __token__
|
|
39
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
jabberjay-0.0.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 The Alan Turing Institute
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
jabberjay-0.0.3/PKG-INFO
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: Jabberjay
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: 🦜 Synthetic Voice Detection
|
|
5
|
+
Project-URL: Homepage, https://github.com/MattyB95/Jabberjay
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/MattyB95/Jabberjay/issues
|
|
7
|
+
Author-email: Matthew Boakes <mboakes@turing.ac.uk>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: Detection,Synthetic,Voice
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: <3.12,>=3.10
|
|
15
|
+
Requires-Dist: joblib
|
|
16
|
+
Requires-Dist: librosa
|
|
17
|
+
Requires-Dist: matplotlib
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: pillow
|
|
20
|
+
Requires-Dist: pyyaml
|
|
21
|
+
Requires-Dist: scikit-learn
|
|
22
|
+
Requires-Dist: soundfile
|
|
23
|
+
Requires-Dist: torch
|
|
24
|
+
Requires-Dist: transformers
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: build; extra == 'dev'
|
|
27
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
28
|
+
Requires-Dist: twine; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# Jabberjay
|
|
32
|
+
|
|
33
|
+
🦜 Synthetic Voice Detection
|
|
34
|
+
|
|
35
|
+
## Models
|
|
36
|
+
|
|
37
|
+
### Vision Transformer
|
|
38
|
+
|
|
39
|
+
| **Name** | **Model** | **Dataset** | **Visualisation** | **Model** |
|
|
40
|
+
|----------------------------------------------------------------------|-----------|---------------|-------------------|-------------------------------------------------------------------------------------------------------------|
|
|
41
|
+
| MattyB95/VIT-ASVspoof2019-Mel_Spectrogram-Synthetic-Voice-Detection | VIT | ASVspoof2019 | MelSpectrogram | [Hugging Face](https://huggingface.co/MattyB95/VIT-ASVspoof2019-Mel_Spectrogram-Synthetic-Voice-Detection) |
|
|
42
|
+
| MattyB95/VIT-ASVspoof2019-ConstantQ-Synthetic-Voice-Detection | VIT | ASVspoof2019 | ConstantQ | [Hugging Face](https://huggingface.co/MattyB95/VIT-ASVspoof2019-ConstantQ-Synthetic-Voice-Detection) |
|
|
43
|
+
| MattyB95/VIT-ASVspoof2019-MFCC-Synthetic-Voice-Detection | VIT | ASVspoof2019 | MFCC | [Hugging Face](https://huggingface.co/MattyB95/VIT-ASVspoof2019-MFCC-Synthetic-Voice-Detection) |
|
|
44
|
+
| MattyB95/VIT-VoxCelebSpoof-Mel_Spectrogram-Synthetic-Voice-Detection | VIT | VoxCelebSpoof | MelSpectrogram | [Hugging Face](https://huggingface.co/MattyB95/VIT-VoxCelebSpoof-Mel_Spectrogram-Synthetic-Voice-Detection) |
|
|
45
|
+
| MattyB95/VIT-VoxCelebSpoof-ConstantQ-Synthetic-Voice-Detection | VIT | VoxCelebSpoof | ConstantQ | [Hugging Face](https://huggingface.co/MattyB95/VIT-VoxCelebSpoof-ConstantQ-Synthetic-Voice-Detection) |
|
|
46
|
+
| MattyB95/VIT-VoxCelebSpoof-MFCC-Synthetic-Voice-Detection | VIT | VoxCelebSpoof | MFCC | [Hugging Face](https://huggingface.co/MattyB95/VIT-VoxCelebSpoof-MFCC-Synthetic-Voice-Detection) |
|
|
47
|
+
|
|
48
|
+
### Audio Spectrogram Transformer
|
|
49
|
+
|
|
50
|
+
| **Name** | **Model** | **Dataset** | **Model** |
|
|
51
|
+
|------------------------------------------------------|-----------|---------------|---------------------------------------------------------------------------------------------|
|
|
52
|
+
| MattyB95/AST-ASVspoof2019-Synthetic-Voice-Detection | AST | ASVspoof2019 | [Hugging Face](https://huggingface.co/MattyB95/AST-ASVspoof2019-Synthetic-Voice-Detection) |
|
|
53
|
+
| MattyB95/AST-VoxCelebSpoof-Synthetic-Voice-Detection | AST | VoxCelebSpoof | [Hugging Face](https://huggingface.co/MattyB95/AST-VoxCelebSpoof-Synthetic-Voice-Detection) |
|
|
54
|
+
|
|
55
|
+
### Other
|
|
56
|
+
|
|
57
|
+
| Name | Paper | Codebase | Model |
|
|
58
|
+
|-----------|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
|
|
59
|
+
| Classical | Placeholder | Placeholder | Placeholder |
|
|
60
|
+
| RawNet2 | [End-to-End anti-spoofing with RawNet2](https://doi.org/10.1109/ICASSP39728.2021.9414234) | [rawnet2-antispoofing](https://github.com/eurecom-asp/rawnet2-antispoofing) | [pre_trained_DF_RawNet2.zip](https://www.asvspoof.org/asvspoof2021/pre_trained_DF_RawNet2.zip) |
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Command Line Interface
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
usage: Jabberjay [-h] [-m {AST,Classical,RawNet2,VIT}]
|
|
68
|
+
[-d {ASVspoof2019,VoxCelebSpoof}]
|
|
69
|
+
[-vis {ConstantQ,MelSpectrogram,MFCC}] [-v]
|
|
70
|
+
audio
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Python API
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
from Jabberjay.Utilities.enum_handler import Visualisation, Model, Dataset
|
|
77
|
+
from Jabberjay.jabberjay import Jabberjay
|
|
78
|
+
|
|
79
|
+
jabberjay = Jabberjay()
|
|
80
|
+
|
|
81
|
+
bonafide = jabberjay.load(filename="../res/bonafide/bonafide.flac")
|
|
82
|
+
spoof = jabberjay.load(filename="../res/spoof/spoof.flac")
|
|
83
|
+
|
|
84
|
+
jabberjay.detect(audio=bonafide, model=Model.VIT, visualisation=Visualisation.ConstantQ, dataset=Dataset.VoxCelebSpoof)
|
|
85
|
+
jabberjay.detect(audio=spoof, model=Model.VIT, visualisation=Visualisation.ConstantQ, dataset=Dataset.VoxCelebSpoof)
|
|
86
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Jabberjay
|
|
2
|
+
|
|
3
|
+
🦜 Synthetic Voice Detection
|
|
4
|
+
|
|
5
|
+
## Models
|
|
6
|
+
|
|
7
|
+
### Vision Transformer
|
|
8
|
+
|
|
9
|
+
| **Name** | **Model** | **Dataset** | **Visualisation** | **Model** |
|
|
10
|
+
|----------------------------------------------------------------------|-----------|---------------|-------------------|-------------------------------------------------------------------------------------------------------------|
|
|
11
|
+
| MattyB95/VIT-ASVspoof2019-Mel_Spectrogram-Synthetic-Voice-Detection | VIT | ASVspoof2019 | MelSpectrogram | [Hugging Face](https://huggingface.co/MattyB95/VIT-ASVspoof2019-Mel_Spectrogram-Synthetic-Voice-Detection) |
|
|
12
|
+
| MattyB95/VIT-ASVspoof2019-ConstantQ-Synthetic-Voice-Detection | VIT | ASVspoof2019 | ConstantQ | [Hugging Face](https://huggingface.co/MattyB95/VIT-ASVspoof2019-ConstantQ-Synthetic-Voice-Detection) |
|
|
13
|
+
| MattyB95/VIT-ASVspoof2019-MFCC-Synthetic-Voice-Detection | VIT | ASVspoof2019 | MFCC | [Hugging Face](https://huggingface.co/MattyB95/VIT-ASVspoof2019-MFCC-Synthetic-Voice-Detection) |
|
|
14
|
+
| MattyB95/VIT-VoxCelebSpoof-Mel_Spectrogram-Synthetic-Voice-Detection | VIT | VoxCelebSpoof | MelSpectrogram | [Hugging Face](https://huggingface.co/MattyB95/VIT-VoxCelebSpoof-Mel_Spectrogram-Synthetic-Voice-Detection) |
|
|
15
|
+
| MattyB95/VIT-VoxCelebSpoof-ConstantQ-Synthetic-Voice-Detection | VIT | VoxCelebSpoof | ConstantQ | [Hugging Face](https://huggingface.co/MattyB95/VIT-VoxCelebSpoof-ConstantQ-Synthetic-Voice-Detection) |
|
|
16
|
+
| MattyB95/VIT-VoxCelebSpoof-MFCC-Synthetic-Voice-Detection | VIT | VoxCelebSpoof | MFCC | [Hugging Face](https://huggingface.co/MattyB95/VIT-VoxCelebSpoof-MFCC-Synthetic-Voice-Detection) |
|
|
17
|
+
|
|
18
|
+
### Audio Spectrogram Transformer
|
|
19
|
+
|
|
20
|
+
| **Name** | **Model** | **Dataset** | **Model** |
|
|
21
|
+
|------------------------------------------------------|-----------|---------------|---------------------------------------------------------------------------------------------|
|
|
22
|
+
| MattyB95/AST-ASVspoof2019-Synthetic-Voice-Detection | AST | ASVspoof2019 | [Hugging Face](https://huggingface.co/MattyB95/AST-ASVspoof2019-Synthetic-Voice-Detection) |
|
|
23
|
+
| MattyB95/AST-VoxCelebSpoof-Synthetic-Voice-Detection | AST | VoxCelebSpoof | [Hugging Face](https://huggingface.co/MattyB95/AST-VoxCelebSpoof-Synthetic-Voice-Detection) |
|
|
24
|
+
|
|
25
|
+
### Other
|
|
26
|
+
|
|
27
|
+
| Name | Paper | Codebase | Model |
|
|
28
|
+
|-----------|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
|
|
29
|
+
| Classical | Placeholder | Placeholder | Placeholder |
|
|
30
|
+
| RawNet2 | [End-to-End anti-spoofing with RawNet2](https://doi.org/10.1109/ICASSP39728.2021.9414234) | [rawnet2-antispoofing](https://github.com/eurecom-asp/rawnet2-antispoofing) | [pre_trained_DF_RawNet2.zip](https://www.asvspoof.org/asvspoof2021/pre_trained_DF_RawNet2.zip) |
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Command Line Interface
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
usage: Jabberjay [-h] [-m {AST,Classical,RawNet2,VIT}]
|
|
38
|
+
[-d {ASVspoof2019,VoxCelebSpoof}]
|
|
39
|
+
[-vis {ConstantQ,MelSpectrogram,MFCC}] [-v]
|
|
40
|
+
audio
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Python API
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
from Jabberjay.Utilities.enum_handler import Visualisation, Model, Dataset
|
|
47
|
+
from Jabberjay.jabberjay import Jabberjay
|
|
48
|
+
|
|
49
|
+
jabberjay = Jabberjay()
|
|
50
|
+
|
|
51
|
+
bonafide = jabberjay.load(filename="../res/bonafide/bonafide.flac")
|
|
52
|
+
spoof = jabberjay.load(filename="../res/spoof/spoof.flac")
|
|
53
|
+
|
|
54
|
+
jabberjay.detect(audio=bonafide, model=Model.VIT, visualisation=Visualisation.ConstantQ, dataset=Dataset.VoxCelebSpoof)
|
|
55
|
+
jabberjay.detect(audio=spoof, model=Model.VIT, visualisation=Visualisation.ConstantQ, dataset=Dataset.VoxCelebSpoof)
|
|
56
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from Jabberjay.Utilities.enum_handler import Visualisation, Model, Dataset
|
|
2
|
+
from Jabberjay.jabberjay import Jabberjay
|
|
3
|
+
|
|
4
|
+
jabberjay = Jabberjay()
|
|
5
|
+
|
|
6
|
+
jabberjay.list_models()
|
|
7
|
+
jabberjay.list_datasets()
|
|
8
|
+
jabberjay.list_visualisations()
|
|
9
|
+
|
|
10
|
+
bonafide = jabberjay.load(filename="../res/bonafide/bonafide.flac")
|
|
11
|
+
spoof = jabberjay.load(filename="../res/spoof/spoof.flac")
|
|
12
|
+
|
|
13
|
+
# Bonafide
|
|
14
|
+
print("")
|
|
15
|
+
print("Bonafide")
|
|
16
|
+
jabberjay.detect(audio=bonafide, model=Model.Classical)
|
|
17
|
+
|
|
18
|
+
jabberjay.detect(audio=bonafide, model=Model.RawNet2)
|
|
19
|
+
|
|
20
|
+
jabberjay.detect(
|
|
21
|
+
audio=bonafide,
|
|
22
|
+
model=Model.VIT,
|
|
23
|
+
visualisation=Visualisation.ConstantQ,
|
|
24
|
+
dataset=Dataset.ASVspoof2019,
|
|
25
|
+
)
|
|
26
|
+
jabberjay.detect(
|
|
27
|
+
audio=bonafide,
|
|
28
|
+
model=Model.VIT,
|
|
29
|
+
visualisation=Visualisation.ConstantQ,
|
|
30
|
+
dataset=Dataset.VoxCelebSpoof,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
jabberjay.detect(
|
|
34
|
+
audio=bonafide,
|
|
35
|
+
model=Model.VIT,
|
|
36
|
+
visualisation=Visualisation.MelSpectrogram,
|
|
37
|
+
dataset=Dataset.ASVspoof2019,
|
|
38
|
+
)
|
|
39
|
+
jabberjay.detect(
|
|
40
|
+
audio=bonafide,
|
|
41
|
+
model=Model.VIT,
|
|
42
|
+
visualisation=Visualisation.MelSpectrogram,
|
|
43
|
+
dataset=Dataset.VoxCelebSpoof,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
jabberjay.detect(
|
|
47
|
+
audio=bonafide,
|
|
48
|
+
model=Model.VIT,
|
|
49
|
+
visualisation=Visualisation.MFCC,
|
|
50
|
+
dataset=Dataset.ASVspoof2019,
|
|
51
|
+
)
|
|
52
|
+
jabberjay.detect(
|
|
53
|
+
audio=bonafide,
|
|
54
|
+
model=Model.VIT,
|
|
55
|
+
visualisation=Visualisation.MFCC,
|
|
56
|
+
dataset=Dataset.VoxCelebSpoof,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
jabberjay.detect(audio=bonafide, model=Model.AST, dataset=Dataset.ASVspoof2019)
|
|
60
|
+
jabberjay.detect(audio=bonafide, model=Model.AST, dataset=Dataset.VoxCelebSpoof)
|
|
61
|
+
|
|
62
|
+
# Spoof
|
|
63
|
+
print("")
|
|
64
|
+
print("Spoof")
|
|
65
|
+
jabberjay.detect(audio=spoof, model=Model.Classical)
|
|
66
|
+
|
|
67
|
+
jabberjay.detect(audio=spoof, model=Model.RawNet2)
|
|
68
|
+
|
|
69
|
+
jabberjay.detect(
|
|
70
|
+
audio=spoof,
|
|
71
|
+
model=Model.VIT,
|
|
72
|
+
visualisation=Visualisation.ConstantQ,
|
|
73
|
+
dataset=Dataset.ASVspoof2019,
|
|
74
|
+
)
|
|
75
|
+
jabberjay.detect(
|
|
76
|
+
audio=spoof,
|
|
77
|
+
model=Model.VIT,
|
|
78
|
+
visualisation=Visualisation.ConstantQ,
|
|
79
|
+
dataset=Dataset.VoxCelebSpoof,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
jabberjay.detect(
|
|
83
|
+
audio=spoof,
|
|
84
|
+
model=Model.VIT,
|
|
85
|
+
visualisation=Visualisation.MelSpectrogram,
|
|
86
|
+
dataset=Dataset.ASVspoof2019,
|
|
87
|
+
)
|
|
88
|
+
jabberjay.detect(
|
|
89
|
+
audio=spoof,
|
|
90
|
+
model=Model.VIT,
|
|
91
|
+
visualisation=Visualisation.MelSpectrogram,
|
|
92
|
+
dataset=Dataset.VoxCelebSpoof,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
jabberjay.detect(
|
|
96
|
+
audio=spoof,
|
|
97
|
+
model=Model.VIT,
|
|
98
|
+
visualisation=Visualisation.MFCC,
|
|
99
|
+
dataset=Dataset.ASVspoof2019,
|
|
100
|
+
)
|
|
101
|
+
jabberjay.detect(
|
|
102
|
+
audio=spoof,
|
|
103
|
+
model=Model.VIT,
|
|
104
|
+
visualisation=Visualisation.MFCC,
|
|
105
|
+
dataset=Dataset.VoxCelebSpoof,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
jabberjay.detect(audio=spoof, model=Model.AST, dataset=Dataset.ASVspoof2019)
|
|
109
|
+
jabberjay.detect(audio=spoof, model=Model.AST, dataset=Dataset.VoxCelebSpoof)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Jabberjay"
|
|
7
|
+
version = "0.0.3"
|
|
8
|
+
description = "🦜 Synthetic Voice Detection"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10,<3.12"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Matthew Boakes", email = "mboakes@turing.ac.uk" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"Synthetic",
|
|
17
|
+
"Voice",
|
|
18
|
+
"Detection",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"joblib",
|
|
27
|
+
"librosa",
|
|
28
|
+
"matplotlib",
|
|
29
|
+
"numpy",
|
|
30
|
+
"Pillow",
|
|
31
|
+
"PyYAML",
|
|
32
|
+
"scikit-learn",
|
|
33
|
+
"soundfile",
|
|
34
|
+
"torch",
|
|
35
|
+
"transformers",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
"Homepage" = "https://github.com/MattyB95/Jabberjay"
|
|
40
|
+
"Bug Tracker" = "https://github.com/MattyB95/Jabberjay/issues"
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
dev = [
|
|
44
|
+
"build",
|
|
45
|
+
"pre-commit",
|
|
46
|
+
"twine",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.scripts]
|
|
50
|
+
jabberjay = "Jabberjay.jabberjay:main"
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.wheel]
|
|
53
|
+
packages = ["src/Jabberjay"]
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import librosa
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def feature_chromagram(y: np.ndarray, sr: float) -> np.ndarray:
|
|
6
|
+
stft_spectrogram = np.abs(librosa.stft(y))
|
|
7
|
+
chromagram = np.mean(
|
|
8
|
+
librosa.feature.chroma_stft(S=stft_spectrogram, sr=sr).T, axis=0
|
|
9
|
+
)
|
|
10
|
+
return chromagram
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def feature_melspectrogram(y: np.ndarray, sr: float) -> np.ndarray:
|
|
14
|
+
melspectrogram = np.mean(
|
|
15
|
+
librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128, fmax=8000).T, axis=0
|
|
16
|
+
)
|
|
17
|
+
return melspectrogram
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def feature_mfcc(y: np.ndarray, sr: float) -> np.ndarray:
|
|
21
|
+
mfc_coefficients = np.mean(librosa.feature.mfcc(y=y, sr=sr, n_mfcc=40).T, axis=0)
|
|
22
|
+
return mfc_coefficients
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_features(audio: tuple[np.ndarray, float]) -> np.ndarray:
|
|
26
|
+
y, sr = audio
|
|
27
|
+
chromagram = feature_chromagram(y, sr)
|
|
28
|
+
melspectrogram = feature_melspectrogram(y, sr)
|
|
29
|
+
mfc_coefficients = feature_mfcc(y, sr)
|
|
30
|
+
feature_matrix = np.hstack((chromagram, melspectrogram, mfc_coefficients))
|
|
31
|
+
return feature_matrix.reshape(1, -1)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from joblib import load
|
|
5
|
+
from sklearn.preprocessing import StandardScaler
|
|
6
|
+
|
|
7
|
+
from Jabberjay.Models.Classical.feature_extraction import get_features
|
|
8
|
+
from Jabberjay.Utilities.hugging_face import download_pretrained_model
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def predict(audio: tuple[np.ndarray, float]):
|
|
12
|
+
repo_id = "MattyB95/Jabberjay_Classical_Machine_Learning_Models"
|
|
13
|
+
filename = "KNeighborsClassifier.joblib"
|
|
14
|
+
logging.info(f"Using Model: {filename}")
|
|
15
|
+
logging.info(f"Repository: {repo_id}")
|
|
16
|
+
model = download_pretrained_model(repo_id=repo_id, filename=filename)
|
|
17
|
+
clf = load(filename=model)
|
|
18
|
+
features = get_features(audio=audio)
|
|
19
|
+
scaler = StandardScaler()
|
|
20
|
+
features_scaled = scaler.fit_transform(X=features)
|
|
21
|
+
return clf.predict(features_scaled)
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
from collections import OrderedDict
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import torch
|
|
5
|
+
import torch.nn as nn
|
|
6
|
+
import torch.nn.functional as F
|
|
7
|
+
from torch import Tensor
|
|
8
|
+
|
|
9
|
+
___author__ = "Hemlata Tak"
|
|
10
|
+
__email__ = "tak@eurecom.fr"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SincConv(nn.Module):
|
|
14
|
+
@staticmethod
|
|
15
|
+
def to_mel(hz):
|
|
16
|
+
return 2595 * np.log10(1 + hz / 700)
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def to_hz(mel):
|
|
20
|
+
return 700 * (10 ** (mel / 2595) - 1)
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
device,
|
|
25
|
+
out_channels,
|
|
26
|
+
kernel_size,
|
|
27
|
+
in_channels=1,
|
|
28
|
+
sample_rate=16000,
|
|
29
|
+
stride=1,
|
|
30
|
+
padding=0,
|
|
31
|
+
dilation=1,
|
|
32
|
+
bias=False,
|
|
33
|
+
groups=1,
|
|
34
|
+
):
|
|
35
|
+
super(SincConv, self).__init__()
|
|
36
|
+
|
|
37
|
+
if in_channels != 1:
|
|
38
|
+
msg = (
|
|
39
|
+
"SincConv only support one input channel (here, in_channels = {%i})"
|
|
40
|
+
% (in_channels)
|
|
41
|
+
)
|
|
42
|
+
raise ValueError(msg)
|
|
43
|
+
|
|
44
|
+
self.out_channels = out_channels
|
|
45
|
+
self.kernel_size = kernel_size
|
|
46
|
+
self.sample_rate = sample_rate
|
|
47
|
+
|
|
48
|
+
# Forcing the filters to be odd (i.e, perfectly symmetrics)
|
|
49
|
+
if kernel_size % 2 == 0:
|
|
50
|
+
self.kernel_size = self.kernel_size + 1
|
|
51
|
+
|
|
52
|
+
self.device = device
|
|
53
|
+
self.stride = stride
|
|
54
|
+
self.padding = padding
|
|
55
|
+
self.dilation = dilation
|
|
56
|
+
|
|
57
|
+
if bias:
|
|
58
|
+
raise ValueError("SincConv does not support bias.")
|
|
59
|
+
if groups > 1:
|
|
60
|
+
raise ValueError("SincConv does not support groups.")
|
|
61
|
+
|
|
62
|
+
# initialize filterbanks using Mel scale
|
|
63
|
+
NFFT = 512
|
|
64
|
+
f = int(self.sample_rate / 2) * np.linspace(0, 1, int(NFFT / 2) + 1)
|
|
65
|
+
fmel = self.to_mel(f) # Hz to mel conversion
|
|
66
|
+
fmelmax = np.max(fmel)
|
|
67
|
+
fmelmin = np.min(fmel)
|
|
68
|
+
filbandwidthsmel = np.linspace(fmelmin, fmelmax, self.out_channels + 1)
|
|
69
|
+
filbandwidthsf = self.to_hz(filbandwidthsmel) # Mel to Hz conversion
|
|
70
|
+
self.mel = filbandwidthsf
|
|
71
|
+
self.hsupp = torch.arange(
|
|
72
|
+
-(self.kernel_size - 1) / 2, (self.kernel_size - 1) / 2 + 1
|
|
73
|
+
)
|
|
74
|
+
self.band_pass = torch.zeros(self.out_channels, self.kernel_size)
|
|
75
|
+
|
|
76
|
+
def forward(self, x):
|
|
77
|
+
for i in range(len(self.mel) - 1):
|
|
78
|
+
fmin = self.mel[i]
|
|
79
|
+
fmax = self.mel[i + 1]
|
|
80
|
+
hHigh = (2 * fmax / self.sample_rate) * np.sinc(
|
|
81
|
+
2 * fmax * self.hsupp / self.sample_rate
|
|
82
|
+
)
|
|
83
|
+
hLow = (2 * fmin / self.sample_rate) * np.sinc(
|
|
84
|
+
2 * fmin * self.hsupp / self.sample_rate
|
|
85
|
+
)
|
|
86
|
+
hideal = hHigh - hLow
|
|
87
|
+
|
|
88
|
+
self.band_pass[i, :] = Tensor(np.hamming(self.kernel_size)) * Tensor(hideal)
|
|
89
|
+
|
|
90
|
+
band_pass_filter = self.band_pass.to(self.device)
|
|
91
|
+
|
|
92
|
+
self.filters = (band_pass_filter).view(self.out_channels, 1, self.kernel_size)
|
|
93
|
+
|
|
94
|
+
return F.conv1d(
|
|
95
|
+
x,
|
|
96
|
+
self.filters,
|
|
97
|
+
stride=self.stride,
|
|
98
|
+
padding=self.padding,
|
|
99
|
+
dilation=self.dilation,
|
|
100
|
+
bias=None,
|
|
101
|
+
groups=1,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class Residual_block(nn.Module):
|
|
106
|
+
def __init__(self, nb_filts, first=False):
|
|
107
|
+
super(Residual_block, self).__init__()
|
|
108
|
+
self.first = first
|
|
109
|
+
|
|
110
|
+
if not self.first:
|
|
111
|
+
self.bn1 = nn.BatchNorm1d(num_features=nb_filts[0])
|
|
112
|
+
|
|
113
|
+
self.lrelu = nn.LeakyReLU(negative_slope=0.3)
|
|
114
|
+
|
|
115
|
+
self.conv1 = nn.Conv1d(
|
|
116
|
+
in_channels=nb_filts[0],
|
|
117
|
+
out_channels=nb_filts[1],
|
|
118
|
+
kernel_size=3,
|
|
119
|
+
padding=1,
|
|
120
|
+
stride=1,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
self.bn2 = nn.BatchNorm1d(num_features=nb_filts[1])
|
|
124
|
+
self.conv2 = nn.Conv1d(
|
|
125
|
+
in_channels=nb_filts[1],
|
|
126
|
+
out_channels=nb_filts[1],
|
|
127
|
+
padding=1,
|
|
128
|
+
kernel_size=3,
|
|
129
|
+
stride=1,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if nb_filts[0] != nb_filts[1]:
|
|
133
|
+
self.downsample = True
|
|
134
|
+
self.conv_downsample = nn.Conv1d(
|
|
135
|
+
in_channels=nb_filts[0],
|
|
136
|
+
out_channels=nb_filts[1],
|
|
137
|
+
padding=0,
|
|
138
|
+
kernel_size=1,
|
|
139
|
+
stride=1,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
else:
|
|
143
|
+
self.downsample = False
|
|
144
|
+
self.mp = nn.MaxPool1d(3)
|
|
145
|
+
|
|
146
|
+
def forward(self, x):
|
|
147
|
+
identity = x
|
|
148
|
+
if not self.first:
|
|
149
|
+
out = self.bn1(x)
|
|
150
|
+
out = self.lrelu(out)
|
|
151
|
+
else:
|
|
152
|
+
out = x
|
|
153
|
+
|
|
154
|
+
out = self.conv1(x)
|
|
155
|
+
out = self.bn2(out)
|
|
156
|
+
out = self.lrelu(out)
|
|
157
|
+
out = self.conv2(out)
|
|
158
|
+
|
|
159
|
+
if self.downsample:
|
|
160
|
+
identity = self.conv_downsample(identity)
|
|
161
|
+
|
|
162
|
+
out += identity
|
|
163
|
+
out = self.mp(out)
|
|
164
|
+
return out
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class RawNet(nn.Module):
|
|
168
|
+
def __init__(self, d_args, device):
|
|
169
|
+
super(RawNet, self).__init__()
|
|
170
|
+
|
|
171
|
+
self.device = device
|
|
172
|
+
|
|
173
|
+
self.Sinc_conv = SincConv(
|
|
174
|
+
device=self.device,
|
|
175
|
+
out_channels=d_args["filts"][0],
|
|
176
|
+
kernel_size=d_args["first_conv"],
|
|
177
|
+
in_channels=d_args["in_channels"],
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
self.first_bn = nn.BatchNorm1d(num_features=d_args["filts"][0])
|
|
181
|
+
self.selu = nn.SELU(inplace=True)
|
|
182
|
+
self.block0 = nn.Sequential(
|
|
183
|
+
Residual_block(nb_filts=d_args["filts"][1], first=True)
|
|
184
|
+
)
|
|
185
|
+
self.block1 = nn.Sequential(Residual_block(nb_filts=d_args["filts"][1]))
|
|
186
|
+
self.block2 = nn.Sequential(Residual_block(nb_filts=d_args["filts"][2]))
|
|
187
|
+
d_args["filts"][2][0] = d_args["filts"][2][1]
|
|
188
|
+
self.block3 = nn.Sequential(Residual_block(nb_filts=d_args["filts"][2]))
|
|
189
|
+
self.block4 = nn.Sequential(Residual_block(nb_filts=d_args["filts"][2]))
|
|
190
|
+
self.block5 = nn.Sequential(Residual_block(nb_filts=d_args["filts"][2]))
|
|
191
|
+
self.avgpool = nn.AdaptiveAvgPool1d(1)
|
|
192
|
+
|
|
193
|
+
self.fc_attention0 = self._make_attention_fc(
|
|
194
|
+
in_features=d_args["filts"][1][-1], l_out_features=d_args["filts"][1][-1]
|
|
195
|
+
)
|
|
196
|
+
self.fc_attention1 = self._make_attention_fc(
|
|
197
|
+
in_features=d_args["filts"][1][-1], l_out_features=d_args["filts"][1][-1]
|
|
198
|
+
)
|
|
199
|
+
self.fc_attention2 = self._make_attention_fc(
|
|
200
|
+
in_features=d_args["filts"][2][-1], l_out_features=d_args["filts"][2][-1]
|
|
201
|
+
)
|
|
202
|
+
self.fc_attention3 = self._make_attention_fc(
|
|
203
|
+
in_features=d_args["filts"][2][-1], l_out_features=d_args["filts"][2][-1]
|
|
204
|
+
)
|
|
205
|
+
self.fc_attention4 = self._make_attention_fc(
|
|
206
|
+
in_features=d_args["filts"][2][-1], l_out_features=d_args["filts"][2][-1]
|
|
207
|
+
)
|
|
208
|
+
self.fc_attention5 = self._make_attention_fc(
|
|
209
|
+
in_features=d_args["filts"][2][-1], l_out_features=d_args["filts"][2][-1]
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
self.bn_before_gru = nn.BatchNorm1d(num_features=d_args["filts"][2][-1])
|
|
213
|
+
self.gru = nn.GRU(
|
|
214
|
+
input_size=d_args["filts"][2][-1],
|
|
215
|
+
hidden_size=d_args["gru_node"],
|
|
216
|
+
num_layers=d_args["nb_gru_layer"],
|
|
217
|
+
batch_first=True,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
self.fc1_gru = nn.Linear(
|
|
221
|
+
in_features=d_args["gru_node"], out_features=d_args["nb_fc_node"]
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
self.fc2_gru = nn.Linear(
|
|
225
|
+
in_features=d_args["nb_fc_node"],
|
|
226
|
+
out_features=d_args["nb_classes"],
|
|
227
|
+
bias=True,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
self.sig = nn.Sigmoid()
|
|
231
|
+
self.logsoftmax = nn.LogSoftmax(dim=1)
|
|
232
|
+
|
|
233
|
+
def forward(self, x, y=None):
|
|
234
|
+
nb_samp = x.shape[0]
|
|
235
|
+
len_seq = x.shape[1]
|
|
236
|
+
x = x.view(nb_samp, 1, len_seq)
|
|
237
|
+
|
|
238
|
+
x = self.Sinc_conv(x)
|
|
239
|
+
x = F.max_pool1d(torch.abs(x), 3)
|
|
240
|
+
x = self.first_bn(x)
|
|
241
|
+
x = self.selu(x)
|
|
242
|
+
|
|
243
|
+
x0 = self.block0(x)
|
|
244
|
+
y0 = self.avgpool(x0).view(x0.size(0), -1) # torch.Size([batch, filter])
|
|
245
|
+
y0 = self.fc_attention0(y0)
|
|
246
|
+
y0 = self.sig(y0).view(
|
|
247
|
+
y0.size(0), y0.size(1), -1
|
|
248
|
+
) # torch.Size([batch, filter, 1])
|
|
249
|
+
x = x0 * y0 + y0 # (batch, filter, time) x (batch, filter, 1)
|
|
250
|
+
|
|
251
|
+
x1 = self.block1(x)
|
|
252
|
+
y1 = self.avgpool(x1).view(x1.size(0), -1) # torch.Size([batch, filter])
|
|
253
|
+
y1 = self.fc_attention1(y1)
|
|
254
|
+
y1 = self.sig(y1).view(
|
|
255
|
+
y1.size(0), y1.size(1), -1
|
|
256
|
+
) # torch.Size([batch, filter, 1])
|
|
257
|
+
x = x1 * y1 + y1 # (batch, filter, time) x (batch, filter, 1)
|
|
258
|
+
|
|
259
|
+
x2 = self.block2(x)
|
|
260
|
+
y2 = self.avgpool(x2).view(x2.size(0), -1) # torch.Size([batch, filter])
|
|
261
|
+
y2 = self.fc_attention2(y2)
|
|
262
|
+
y2 = self.sig(y2).view(
|
|
263
|
+
y2.size(0), y2.size(1), -1
|
|
264
|
+
) # torch.Size([batch, filter, 1])
|
|
265
|
+
x = x2 * y2 + y2 # (batch, filter, time) x (batch, filter, 1)
|
|
266
|
+
|
|
267
|
+
x3 = self.block3(x)
|
|
268
|
+
y3 = self.avgpool(x3).view(x3.size(0), -1) # torch.Size([batch, filter])
|
|
269
|
+
y3 = self.fc_attention3(y3)
|
|
270
|
+
y3 = self.sig(y3).view(
|
|
271
|
+
y3.size(0), y3.size(1), -1
|
|
272
|
+
) # torch.Size([batch, filter, 1])
|
|
273
|
+
x = x3 * y3 + y3 # (batch, filter, time) x (batch, filter, 1)
|
|
274
|
+
|
|
275
|
+
x4 = self.block4(x)
|
|
276
|
+
y4 = self.avgpool(x4).view(x4.size(0), -1) # torch.Size([batch, filter])
|
|
277
|
+
y4 = self.fc_attention4(y4)
|
|
278
|
+
y4 = self.sig(y4).view(
|
|
279
|
+
y4.size(0), y4.size(1), -1
|
|
280
|
+
) # torch.Size([batch, filter, 1])
|
|
281
|
+
x = x4 * y4 + y4 # (batch, filter, time) x (batch, filter, 1)
|
|
282
|
+
|
|
283
|
+
x5 = self.block5(x)
|
|
284
|
+
y5 = self.avgpool(x5).view(x5.size(0), -1) # torch.Size([batch, filter])
|
|
285
|
+
y5 = self.fc_attention5(y5)
|
|
286
|
+
y5 = self.sig(y5).view(
|
|
287
|
+
y5.size(0), y5.size(1), -1
|
|
288
|
+
) # torch.Size([batch, filter, 1])
|
|
289
|
+
x = x5 * y5 + y5 # (batch, filter, time) x (batch, filter, 1)
|
|
290
|
+
|
|
291
|
+
x = self.bn_before_gru(x)
|
|
292
|
+
x = self.selu(x)
|
|
293
|
+
x = x.permute(0, 2, 1) # (batch, filt, time) >> (batch, time, filt)
|
|
294
|
+
self.gru.flatten_parameters()
|
|
295
|
+
x, _ = self.gru(x)
|
|
296
|
+
x = x[:, -1, :]
|
|
297
|
+
x = self.fc1_gru(x)
|
|
298
|
+
x = self.fc2_gru(x)
|
|
299
|
+
output = self.logsoftmax(x)
|
|
300
|
+
|
|
301
|
+
return output
|
|
302
|
+
|
|
303
|
+
def _make_attention_fc(self, in_features, l_out_features):
|
|
304
|
+
l_fc = []
|
|
305
|
+
|
|
306
|
+
l_fc.append(nn.Linear(in_features=in_features, out_features=l_out_features))
|
|
307
|
+
|
|
308
|
+
return nn.Sequential(*l_fc)
|
|
309
|
+
|
|
310
|
+
def _make_layer(self, nb_blocks, nb_filts, first=False):
|
|
311
|
+
layers = []
|
|
312
|
+
# def __init__(self, nb_filts, first = False):
|
|
313
|
+
for i in range(nb_blocks):
|
|
314
|
+
first = first if i == 0 else False
|
|
315
|
+
layers.append(Residual_block(nb_filts=nb_filts, first=first))
|
|
316
|
+
if i == 0:
|
|
317
|
+
nb_filts[0] = nb_filts[1]
|
|
318
|
+
|
|
319
|
+
return nn.Sequential(*layers)
|
|
320
|
+
|
|
321
|
+
def summary(self, input_size, batch_size=-1, device="cuda", print_fn=None):
|
|
322
|
+
model = self
|
|
323
|
+
|
|
324
|
+
def register_hook(module):
|
|
325
|
+
def hook(module, input, output):
|
|
326
|
+
class_name = str(module.__class__).split(".")[-1].split("'")[0]
|
|
327
|
+
module_idx = len(summary)
|
|
328
|
+
|
|
329
|
+
m_key = "%s-%i" % (class_name, module_idx + 1)
|
|
330
|
+
summary[m_key] = OrderedDict()
|
|
331
|
+
summary[m_key]["input_shape"] = list(input[0].size())
|
|
332
|
+
summary[m_key]["input_shape"][0] = batch_size
|
|
333
|
+
if isinstance(output, (list, tuple)):
|
|
334
|
+
summary[m_key]["output_shape"] = [
|
|
335
|
+
[-1] + list(o.size())[1:] for o in output
|
|
336
|
+
]
|
|
337
|
+
else:
|
|
338
|
+
summary[m_key]["output_shape"] = list(output.size())
|
|
339
|
+
if len(summary[m_key]["output_shape"]) != 0:
|
|
340
|
+
summary[m_key]["output_shape"][0] = batch_size
|
|
341
|
+
|
|
342
|
+
params = 0
|
|
343
|
+
if hasattr(module, "weight") and hasattr(module.weight, "size"):
|
|
344
|
+
params += torch.prod(torch.LongTensor(list(module.weight.size())))
|
|
345
|
+
summary[m_key]["trainable"] = module.weight.requires_grad
|
|
346
|
+
if hasattr(module, "bias") and hasattr(module.bias, "size"):
|
|
347
|
+
params += torch.prod(torch.LongTensor(list(module.bias.size())))
|
|
348
|
+
summary[m_key]["nb_params"] = params
|
|
349
|
+
|
|
350
|
+
if (
|
|
351
|
+
not isinstance(module, nn.Sequential)
|
|
352
|
+
and not isinstance(module, nn.ModuleList)
|
|
353
|
+
and not (module == model)
|
|
354
|
+
):
|
|
355
|
+
hooks.append(module.register_forward_hook(hook))
|
|
356
|
+
|
|
357
|
+
device = device.lower()
|
|
358
|
+
assert device in [
|
|
359
|
+
"cuda",
|
|
360
|
+
"cpu",
|
|
361
|
+
], "Input device is not valid, please specify 'cuda' or 'cpu'"
|
|
362
|
+
|
|
363
|
+
if device == "cuda" and torch.cuda.is_available():
|
|
364
|
+
dtype = torch.cuda.FloatTensor
|
|
365
|
+
else:
|
|
366
|
+
dtype = torch.FloatTensor
|
|
367
|
+
if isinstance(input_size, tuple):
|
|
368
|
+
input_size = [input_size]
|
|
369
|
+
x = [torch.rand(2, *in_size).type(dtype) for in_size in input_size]
|
|
370
|
+
summary = OrderedDict()
|
|
371
|
+
hooks = []
|
|
372
|
+
model.apply(register_hook)
|
|
373
|
+
model(*x)
|
|
374
|
+
for h in hooks:
|
|
375
|
+
h.remove()
|
|
376
|
+
|
|
377
|
+
print_fn("----------------------------------------------------------------")
|
|
378
|
+
line_new = "{:>20} {:>25} {:>15}".format(
|
|
379
|
+
"Layer (type)", "Output Shape", "Param #"
|
|
380
|
+
)
|
|
381
|
+
print_fn(line_new)
|
|
382
|
+
print_fn("================================================================")
|
|
383
|
+
total_params = 0
|
|
384
|
+
total_output = 0
|
|
385
|
+
trainable_params = 0
|
|
386
|
+
for layer in summary:
|
|
387
|
+
# input_shape, output_shape, trainable, nb_params
|
|
388
|
+
line_new = "{:>20} {:>25} {:>15}".format(
|
|
389
|
+
layer,
|
|
390
|
+
str(summary[layer]["output_shape"]),
|
|
391
|
+
"{0:,}".format(summary[layer]["nb_params"]),
|
|
392
|
+
)
|
|
393
|
+
total_params += summary[layer]["nb_params"]
|
|
394
|
+
total_output += np.prod(summary[layer]["output_shape"])
|
|
395
|
+
if "trainable" in summary[layer]:
|
|
396
|
+
if summary[layer]["trainable"]:
|
|
397
|
+
trainable_params += summary[layer]["nb_params"]
|
|
398
|
+
print_fn(line_new)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
optimizer: Adam
|
|
2
|
+
amsgrad: 1 #for adam optim
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#model-related
|
|
7
|
+
model:
|
|
8
|
+
nb_samp: 64600
|
|
9
|
+
first_conv: 1024 # no. of filter coefficients
|
|
10
|
+
in_channels: 1
|
|
11
|
+
filts: [20, [20, 20], [20, 128], [128, 128]] # no. of filters channel in residual blocks
|
|
12
|
+
blocks: [2, 4]
|
|
13
|
+
nb_fc_node: 1024
|
|
14
|
+
gru_node: 1024
|
|
15
|
+
nb_gru_layer: 3
|
|
16
|
+
nb_classes: 2
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
import torch
|
|
6
|
+
import yaml
|
|
7
|
+
from torch import Tensor
|
|
8
|
+
|
|
9
|
+
from Jabberjay.Models.RawNet2.model import RawNet
|
|
10
|
+
from Jabberjay.Utilities.hugging_face import download_pretrained_model
|
|
11
|
+
|
|
12
|
+
abspath = os.path.abspath(__file__)
|
|
13
|
+
dname = os.path.dirname(abspath)
|
|
14
|
+
os.chdir(dname)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def predict(y: np.ndarray):
|
|
18
|
+
with open("./model_config_RawNet.yaml", "r") as f_yaml:
|
|
19
|
+
parser = yaml.safe_load(f_yaml)
|
|
20
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
21
|
+
logging.info(f"Device: {device}")
|
|
22
|
+
model = RawNet(parser["model"], device)
|
|
23
|
+
model.to(device)
|
|
24
|
+
repo_id = "MattyB95/pre_trained_DF_RawNet2"
|
|
25
|
+
logging.info(f"Using model: {repo_id}")
|
|
26
|
+
model_file = download_pretrained_model(
|
|
27
|
+
repo_id=repo_id, filename="pre_trained_DF_RawNet2.pth"
|
|
28
|
+
)
|
|
29
|
+
model.load_state_dict(torch.load(model_file, map_location=torch.device(device)))
|
|
30
|
+
model.eval()
|
|
31
|
+
y = Tensor(y).unsqueeze(0).to(device)
|
|
32
|
+
with torch.no_grad():
|
|
33
|
+
out = model(y)
|
|
34
|
+
_, predicted = out.max(dim=1)
|
|
35
|
+
return predicted
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from transformers import pipeline
|
|
5
|
+
|
|
6
|
+
from Jabberjay.Utilities.enum_handler import Dataset
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def predict(y: np.ndarray, dataset: Dataset) -> list[dict[str, float]]:
|
|
10
|
+
model = f"MattyB95/AST-{dataset.value}-Synthetic-Voice-Detection"
|
|
11
|
+
logging.info(f"Using model: {model}")
|
|
12
|
+
pipe = pipeline("audio-classification", model=model)
|
|
13
|
+
return pipe(y)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import librosa
|
|
4
|
+
import numpy as np
|
|
5
|
+
from transformers import pipeline
|
|
6
|
+
|
|
7
|
+
from Jabberjay.Models.Tranformer.VIT.utility import get_image
|
|
8
|
+
from Jabberjay.Utilities.enum_handler import Dataset
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def predict(
|
|
12
|
+
audio: tuple[np.ndarray, float], dataset: Dataset
|
|
13
|
+
) -> list[dict[str, float]]:
|
|
14
|
+
y, sr = audio
|
|
15
|
+
model = f"MattyB95/VIT-{dataset.value}-ConstantQ-Synthetic-Voice-Detection"
|
|
16
|
+
logging.info(f"Using Model: {model}")
|
|
17
|
+
pipe = pipeline(task="image-classification", model=model)
|
|
18
|
+
CQT = np.abs(librosa.cqt(y=y, sr=sr))
|
|
19
|
+
S_db = librosa.amplitude_to_db(S=CQT, ref=np.max)
|
|
20
|
+
image = get_image(data=S_db, sr=sr)
|
|
21
|
+
return pipe(image)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import librosa
|
|
4
|
+
import numpy as np
|
|
5
|
+
from transformers import pipeline
|
|
6
|
+
|
|
7
|
+
from Jabberjay.Models.Tranformer.VIT.utility import get_image
|
|
8
|
+
from Jabberjay.Utilities.enum_handler import Dataset
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def predict(
|
|
12
|
+
audio: tuple[np.ndarray, float], dataset: Dataset
|
|
13
|
+
) -> list[dict[str, float]]:
|
|
14
|
+
y, sr = audio
|
|
15
|
+
model = f"MattyB95/VIT-{dataset.value}-MFCC-Synthetic-Voice-Detection"
|
|
16
|
+
logging.info(f"Using Model: {model}")
|
|
17
|
+
pipe = pipeline("image-classification", model=model)
|
|
18
|
+
M = librosa.feature.mfcc(y=y, sr=sr)
|
|
19
|
+
image = get_image(data=M, sr=sr)
|
|
20
|
+
return pipe(image)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import librosa
|
|
4
|
+
import numpy as np
|
|
5
|
+
from transformers import pipeline
|
|
6
|
+
|
|
7
|
+
from Jabberjay.Models.Tranformer.VIT.utility import get_image
|
|
8
|
+
from Jabberjay.Utilities.enum_handler import Dataset
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def predict(
|
|
12
|
+
audio: tuple[np.ndarray, float], dataset: Dataset
|
|
13
|
+
) -> list[dict[str, float]]:
|
|
14
|
+
y, sr = audio
|
|
15
|
+
model = f"MattyB95/VIT-{dataset.value}-Mel_Spectrogram-Synthetic-Voice-Detection"
|
|
16
|
+
logging.info(f"Using Model: {model}")
|
|
17
|
+
pipe = pipeline(task="image-classification", model=model)
|
|
18
|
+
S = librosa.feature.melspectrogram(y=y, sr=sr)
|
|
19
|
+
S_db = librosa.power_to_db(S=S, ref=np.max)
|
|
20
|
+
image = get_image(data=S_db, sr=sr)
|
|
21
|
+
return pipe(image)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
import librosa
|
|
5
|
+
from PIL import Image
|
|
6
|
+
from matplotlib import pyplot as plt
|
|
7
|
+
from numpy import ndarray
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_image(data: ndarray, sr: float) -> Image.Image:
|
|
11
|
+
fig, ax = plt.subplots()
|
|
12
|
+
librosa.display.specshow(data=data, sr=sr, ax=ax)
|
|
13
|
+
fig.canvas.draw()
|
|
14
|
+
buf = io.BytesIO()
|
|
15
|
+
plt.savefig(buf, bbox_inches="tight", pad_inches=0)
|
|
16
|
+
buf.seek(0)
|
|
17
|
+
if logging.getLogger().level == logging.DEBUG:
|
|
18
|
+
plt.show()
|
|
19
|
+
return Image.open(buf)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Model(Enum):
|
|
6
|
+
AST = "AST"
|
|
7
|
+
Classical = "Classical"
|
|
8
|
+
RawNet2 = "RawNet2"
|
|
9
|
+
VIT = "VIT"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Dataset(Enum):
|
|
13
|
+
ASVspoof2019 = "ASVspoof2019"
|
|
14
|
+
VoxCelebSpoof = "VoxCelebSpoof"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Visualisation(Enum):
|
|
18
|
+
ConstantQ = "ConstantQ"
|
|
19
|
+
MelSpectrogram = "MelSpectrogram"
|
|
20
|
+
MFCC = "MFCC"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class EnumAction(argparse.Action):
|
|
24
|
+
def __init__(self, **kwargs):
|
|
25
|
+
enum_type = kwargs.pop("type", None)
|
|
26
|
+
if enum_type is None:
|
|
27
|
+
raise ValueError("type must be assigned an Enum when using EnumAction")
|
|
28
|
+
if not issubclass(enum_type, Enum):
|
|
29
|
+
raise TypeError("type must be an Enum when using EnumAction")
|
|
30
|
+
kwargs.setdefault("choices", tuple(e.name for e in enum_type))
|
|
31
|
+
|
|
32
|
+
super(EnumAction, self).__init__(**kwargs)
|
|
33
|
+
|
|
34
|
+
self._enum = enum_type
|
|
35
|
+
|
|
36
|
+
def __call__(self, parser, namespace, values, option_string=None):
|
|
37
|
+
value = self._enum[values]
|
|
38
|
+
setattr(namespace, self.dest, value)
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
import librosa
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from Jabberjay.Utilities.enum_handler import EnumAction, Visualisation, Model, Dataset
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Jabberjay:
|
|
11
|
+
@staticmethod
|
|
12
|
+
def list_models():
|
|
13
|
+
print("Models: ", *Model)
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def list_datasets():
|
|
17
|
+
print("Datasets: ", *Dataset)
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def list_visualisations():
|
|
21
|
+
print("Visualisations: ", *Visualisation)
|
|
22
|
+
|
|
23
|
+
def load(self, filename: str) -> tuple[np.ndarray, float]:
|
|
24
|
+
filename = filename
|
|
25
|
+
y, sr = librosa.load(filename)
|
|
26
|
+
return y, sr
|
|
27
|
+
|
|
28
|
+
def detect(
|
|
29
|
+
self,
|
|
30
|
+
audio: tuple[np.ndarray, float],
|
|
31
|
+
model: Model,
|
|
32
|
+
visualisation: Visualisation | None = None,
|
|
33
|
+
dataset: Dataset | None = None,
|
|
34
|
+
) -> None:
|
|
35
|
+
y, sr = audio
|
|
36
|
+
match model:
|
|
37
|
+
case Model.AST:
|
|
38
|
+
self.ast_handler(y=y, dataset=dataset)
|
|
39
|
+
case Model.Classical:
|
|
40
|
+
self.classical_handler(audio=audio)
|
|
41
|
+
case Model.RawNet2:
|
|
42
|
+
self.rawnet2_handler(y=y)
|
|
43
|
+
case Model.VIT:
|
|
44
|
+
self.vit_handler(
|
|
45
|
+
audio=audio, visualisation=visualisation, dataset=dataset
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def ast_handler(self, y, dataset: Dataset) -> None:
|
|
49
|
+
if dataset is None:
|
|
50
|
+
raise ValueError("Dataset Is Required For AST Model!")
|
|
51
|
+
import Jabberjay.Models.Tranformer.AST.run as AST
|
|
52
|
+
|
|
53
|
+
predict = AST.predict(y=y, dataset=dataset)
|
|
54
|
+
logging.info(predict)
|
|
55
|
+
print("Bonafide ✔️" if predict[0].get("label") == "Bonafide" else "Spoof ❌")
|
|
56
|
+
|
|
57
|
+
def classical_handler(self, audio: tuple[np.ndarray, float]) -> None:
|
|
58
|
+
import Jabberjay.Models.Classical.run as Classical
|
|
59
|
+
|
|
60
|
+
predict = Classical.predict(audio=audio)
|
|
61
|
+
logging.info(predict)
|
|
62
|
+
print("Bonafide ✔️" if predict else "Spoof ❌")
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
def rawnet2_handler(self, y) -> None:
|
|
66
|
+
import Jabberjay.Models.RawNet2.run as RawNet2
|
|
67
|
+
|
|
68
|
+
predict = RawNet2.predict(y=y)
|
|
69
|
+
predict = predict.item()
|
|
70
|
+
logging.info(predict)
|
|
71
|
+
print("Bonafide ✔️" if predict else "Spoof ❌")
|
|
72
|
+
|
|
73
|
+
def vit_handler(
|
|
74
|
+
self,
|
|
75
|
+
audio: tuple[np.ndarray, float],
|
|
76
|
+
visualisation: Visualisation,
|
|
77
|
+
dataset: Dataset,
|
|
78
|
+
) -> None:
|
|
79
|
+
if visualisation is None:
|
|
80
|
+
raise ValueError("Visualisation Is Required For VIT Model!")
|
|
81
|
+
if dataset is None:
|
|
82
|
+
raise ValueError("Dataset Is Required For VIT Model!")
|
|
83
|
+
match visualisation:
|
|
84
|
+
case Visualisation.ConstantQ:
|
|
85
|
+
import Jabberjay.Models.Tranformer.VIT.ConstantQ.run as VITConstantQ
|
|
86
|
+
|
|
87
|
+
predict = VITConstantQ.predict(audio=audio, dataset=dataset)
|
|
88
|
+
logging.info(predict)
|
|
89
|
+
print(
|
|
90
|
+
"Bonafide ✔️"
|
|
91
|
+
if predict[0].get("label") == "Bonafide"
|
|
92
|
+
else "Spoof ❌"
|
|
93
|
+
)
|
|
94
|
+
case Visualisation.MelSpectrogram:
|
|
95
|
+
import Jabberjay.Models.Tranformer.VIT.MelSpectrogram.run as VITMelSpectrogram
|
|
96
|
+
|
|
97
|
+
predict = VITMelSpectrogram.predict(audio=audio, dataset=dataset)
|
|
98
|
+
logging.info(predict)
|
|
99
|
+
print(
|
|
100
|
+
"Bonafide ✔️"
|
|
101
|
+
if predict[0].get("label") == "Bonafide"
|
|
102
|
+
else "Spoof ❌"
|
|
103
|
+
)
|
|
104
|
+
case Visualisation.MFCC:
|
|
105
|
+
import Jabberjay.Models.Tranformer.VIT.MFCC.run as VITMFCC
|
|
106
|
+
|
|
107
|
+
predict = VITMFCC.predict(audio=audio, dataset=dataset)
|
|
108
|
+
logging.info(predict)
|
|
109
|
+
print(
|
|
110
|
+
"Bonafide ✔️"
|
|
111
|
+
if predict[0].get("label") == "Bonafide"
|
|
112
|
+
else "Spoof ❌"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def main():
|
|
117
|
+
parser = argparse.ArgumentParser(
|
|
118
|
+
prog="Jabberjay",
|
|
119
|
+
description="🦜 Synthetic Voice Detection",
|
|
120
|
+
epilog="May The Odds Be Ever In Your Favor.",
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
parser.add_argument("audio", type=str)
|
|
124
|
+
parser.add_argument(
|
|
125
|
+
"-m", "--model", type=Model, action=EnumAction, default=Model.VIT
|
|
126
|
+
)
|
|
127
|
+
parser.add_argument(
|
|
128
|
+
"-d",
|
|
129
|
+
"--dataset",
|
|
130
|
+
type=Dataset,
|
|
131
|
+
action=EnumAction,
|
|
132
|
+
default=Dataset.VoxCelebSpoof,
|
|
133
|
+
)
|
|
134
|
+
parser.add_argument(
|
|
135
|
+
"-vis",
|
|
136
|
+
"--visualisation",
|
|
137
|
+
type=Visualisation,
|
|
138
|
+
action=EnumAction,
|
|
139
|
+
default=Visualisation.ConstantQ,
|
|
140
|
+
)
|
|
141
|
+
parser.add_argument("-v", "--verbose", action="store_true")
|
|
142
|
+
|
|
143
|
+
args = parser.parse_args()
|
|
144
|
+
if args.verbose:
|
|
145
|
+
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO)
|
|
146
|
+
logging.info("Verbosity Turned On!")
|
|
147
|
+
else:
|
|
148
|
+
logging.basicConfig(format="%(levelname)s: %(message)s")
|
|
149
|
+
|
|
150
|
+
logging.info(f"Filename: {args.filename}")
|
|
151
|
+
logging.info(f"Model: {args.model}")
|
|
152
|
+
logging.info(f"Dataset: {args.dataset}")
|
|
153
|
+
logging.info(f"Visualisation: {args.visualisation}")
|
|
154
|
+
logging.info(f"Verbose: {args.verbose}")
|
|
155
|
+
|
|
156
|
+
jabberjay = Jabberjay()
|
|
157
|
+
jabberjay.detect(
|
|
158
|
+
audio=jabberjay.load(args.filename),
|
|
159
|
+
model=args.model,
|
|
160
|
+
visualisation=args.visualisation,
|
|
161
|
+
dataset=args.dataset,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
if __name__ == "__main__":
|
|
166
|
+
main()
|