Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #33

Merged
merged 72 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
296efec
Merge pull request #14 from JSchmie/develop
JSchmie Sep 22, 2023
073ca37
Merge pull request #15 from JSchmie/develop
JSchmie Sep 22, 2023
8a5cd15
Update .pyannotetoken
JSchmie Sep 26, 2023
0a7200c
Add files via upload
Tryndaron Nov 17, 2023
2e0989b
Add files via upload
Tryndaron Jan 2, 2024
f90d168
test
Tryndaron Jan 5, 2024
ffe4dc8
test
Tryndaron Jan 5, 2024
f501d76
test
Tryndaron Jan 5, 2024
ee8c980
test
Tryndaron Jan 5, 2024
6f6c31a
test
Tryndaron Jan 5, 2024
fd7e899
test2
Tryndaron Jan 5, 2024
abec1e1
Docstrings
Tryndaron Jan 9, 2024
570048a
Docstrings
Tryndaron Jan 23, 2024
033ce8c
Diarisation
Tryndaron Jan 23, 2024
f872fb1
Autotrancsipt test
Tryndaron Jan 29, 2024
fdb16f2
fixed comments
Tryndaron Mar 15, 2024
e40860c
docstring added and variable type
Tryndaron Mar 21, 2024
22ca00f
Docstrings and global Variables got fixed
Tryndaron Mar 21, 2024
2117353
docstring added
Tryndaron Mar 22, 2024
7cb4010
Merge pull request #36 from JSchmie/tests_diarisation
Tryndaron Mar 25, 2024
20e4614
Merge pull request #35 from JSchmie/tests_audio
Tryndaron Mar 25, 2024
ae3dfb0
audio test files
Tryndaron Mar 25, 2024
169d088
Merge pull request #40 from JSchmie/test_Autotranscipt
JSchmie Mar 25, 2024
fc4f6a0
Tests_diarisation
Tryndaron Mar 25, 2024
beab5df
Merge pull request #60 from JSchmie/tests_diarisation
Tryndaron Mar 25, 2024
b018182
changed folder position
Tryndaron Mar 28, 2024
ab54afd
pytest ci
Tryndaron Mar 28, 2024
72107a6
ci datei
Tryndaron Mar 28, 2024
cce570f
ci datei
Tryndaron Mar 28, 2024
c4d1ecb
ci datei push
Tryndaron Mar 28, 2024
b8ef01f
pip install pytest
Tryndaron Mar 28, 2024
2e9d5b5
token in pyannote geschrieben
Tryndaron Mar 28, 2024
6f9c0c8
ls
Tryndaron Mar 28, 2024
d114841
relativ imports
Tryndaron Apr 2, 2024
f499930
ls removed
Tryndaron Apr 2, 2024
5ee519d
imports
Tryndaron Apr 2, 2024
d458c28
setup install
Tryndaron Apr 2, 2024
d8fa121
setup.py
Tryndaron Apr 2, 2024
b8d9195
-r
Tryndaron Apr 2, 2024
77bfc5e
pipeline operator
Tryndaron Apr 2, 2024
4da3623
setup installation
Tryndaron Apr 2, 2024
cb5be10
pip install setup
Tryndaron Apr 2, 2024
4551933
pip install .
Tryndaron Apr 2, 2024
a3a0491
libsndfile
Tryndaron Apr 2, 2024
566cd5b
sudo
Tryndaron Apr 2, 2024
2f9f86e
removed relative import
Tryndaron Apr 2, 2024
f8e5c2b
hf token destination changed
Tryndaron Apr 3, 2024
2668f6a
hf token given as str
Tryndaron Apr 3, 2024
45ae587
added ffmpeg
Tryndaron Apr 3, 2024
ea8e973
upgrade
Tryndaron Apr 3, 2024
2b4819c
run pytest
Tryndaron Apr 3, 2024
018a2bd
env hf token
Tryndaron Apr 3, 2024
c5e44ec
audio.py
Tryndaron Apr 8, 2024
ccdb125
only audiotest
Tryndaron Apr 8, 2024
eabd573
audiotest 2nd
Tryndaron Apr 8, 2024
c55c12d
only test autotranscript.py
Tryndaron Apr 8, 2024
6663357
spelling error autotranscript test
Tryndaron Apr 8, 2024
a5fb4c9
only test diarisation2.py
Tryndaron Apr 8, 2024
328f7d4
test transcriber function
Tryndaron Apr 9, 2024
f03069b
use all tests
Tryndaron Apr 9, 2024
d1f36eb
fixed diarisation test
Tryndaron Apr 9, 2024
ac9d341
added 3 tests
Tryndaron Apr 10, 2024
fb0c7a9
test if file gets found
Tryndaron Apr 11, 2024
2844ecd
changed file parth
Tryndaron Apr 11, 2024
b4576ab
transcriber class tests
Tryndaron Apr 12, 2024
6144e65
test transcriber
Tryndaron Apr 12, 2024
9340b83
fixed file parth for test file
Tryndaron Apr 12, 2024
54bedc5
removed unneccesary imports
Tryndaron Apr 12, 2024
1e86245
use all tests
Tryndaron Apr 12, 2024
559c2aa
fixed audio file path
Tryndaron Apr 12, 2024
90a90f9
changed trigger of ci to pull-requests only
Tryndaron Apr 12, 2024
ba2eac6
Delete scraibe/.pyannotetoken
JSchmie Apr 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scraibe/.pyannotetoken
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file!

Original file line number Diff line number Diff line change
@@ -1 +1 @@
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

99 changes: 99 additions & 0 deletions scraibe/test/test_audio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import pytest
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unused modules

#from scraibe import Transcriber
#from unittest.mock import patch, mock_open
#import unittest
#import os
from .audio import AudioProcessor
import torch





test_waveform = torch.tensor([]).to('cuda')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please handle cpu as well

test_sr = 16000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global Variables should be upper Case letters

SAMPLE_RATE = 16000
NORMALIZATION_FACTOR = 32768


@pytest.fixture
def probe_audio_processor():
"""_summary_
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add proper doc stings remove summary


Returns:
_type_: _description_
"""
return AudioProcessor(test_waveform, test_sr)






def test_AudioProcessor_init(probe_audio_processor):
"""_summary_

Args:
probe_audio_processor (_type_): _description_
"""
assert isinstance(probe_audio_processor, AudioProcessor)
assert probe_audio_processor.waveform.device == test_waveform.device
assert torch.equal(probe_audio_processor.waveform, test_waveform)
assert probe_audio_processor.sr == test_sr



def test_cut():
"""_summary_
"""
waveform = torch.Tensor(10, 3)
sr = 16000
start = 4
end = 7
assert AudioProcessor(waveform, sr).cut(start, end).size() == int((end - start) * test_sr)



""" def test_cut(probe_audio_processor):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused func

start = 10
end = 100
test_segment = probe_audio_processor.cut(start, end)
print(test_segment)
erwartetes_segment = int((end - start) * test_sr)
print(test_segment.size())
assert len(test_segment) == erwartetes_segment
"""





def test_audio_processor_invalid_sr():
"""_summary_
"""
with pytest.raises(ValueError):
AudioProcessor(test_waveform, [44100,48000])


def test_audio_processor_SAMPLE_RATE():
"""_summary_
"""
probe_audio_processor = AudioProcessor(test_waveform)
assert probe_audio_processor.sr == SAMPLE_RATE

















36 changes: 36 additions & 0 deletions scraibe/test/test_diarisation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pytest
import os
from unittest import mock
from scraibe import Diariser



@pytest.fixture
def diariser_instance():
with mock.patch.object(Diariser, '_get_token', return_value = 'personal Hugging-Face token')
return Diariser('pyannote')



def test_Diariser_init(diariser_instance):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something seems to be wrong here

"""_summary_

Args:
diariser_instance (_type_): _description_
"""
assert diariser_instance.model == 'pyannote'



def test_diarisation_function(diariser_instance):
"""_summary_

Args:
diariser_instance (_type_): _description_
"""
with mock.patch.object(diariser_instance.model, 'apply', return_value='diarization_result'):
diarization_output = diariser_instance.diarization('example_audio_file.wav')
assert diarization_output == 'diarization_result'



29 changes: 29 additions & 0 deletions scraibe/test/test_transcriber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
from unittest.mock import patch
from scraibe import Transcriber




@pytest.mark.parametrize("audio_file, expected_transcription",[("path_to_test_audiofile", "test_transcription")] )
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no spagetti

@patch("scraibe.Transcriber.load_model")

def test_transcriber(mock_load_model, audio_file, expected_transcription):
"""_summary_

Args:
mock_load_model (_type_): _description_
audio_file (_type_): _description_
expected_transcription (_type_): _description_
"""
mock_model = mock_load_model.return_value
mock_model.transcribe.return_value ={"text": expected_transcription}

transcriber = Transcriber.load_model(model="medium")

transcription_result = transcriber.transcribe(audio=audio_file)

assert transcription_result == expected_transcription