Skip to content

Commit

Permalink
add tests for subtitles with accented chars
Browse files Browse the repository at this point in the history
  • Loading branch information
baxtree committed Jun 19, 2024
1 parent 9aa6805 commit 65f7271
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 74 deletions.
8 changes: 5 additions & 3 deletions tests/integration/feature/subaligner.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Feature: Subaligner CLI
| subaligner | single | "test.scc" | "test_aligned.srt" |
| subaligner | single | "test.sbv" | "test_aligned.sbv" |
| subaligner | single | "test.ytt" | "test_aligned.ytt" |
| subaligner | single | "accented.srt" | "accented_aligned.srt" |
| subaligner | dual | "test.srt" | "test_aligned.srt" |
| subaligner | dual | "test.ttml" | "test_aligned.ttml" |
| subaligner | dual | "test.xml" | "test_aligned.xml" |
Expand All @@ -42,6 +43,7 @@ Feature: Subaligner CLI
| subaligner | dual | "test.scc" | "test_aligned.scc" |
| subaligner | dual | "test.sbv" | "test_aligned.sbv" |
| subaligner | dual | "test.ytt" | "test_aligned.ytt" |
| subaligner | dual | "accented.srt" | "accented_aligned.srt" |

@video-input @without-mode
Scenario Outline: Test alignments without modes
Expand Down Expand Up @@ -164,11 +166,11 @@ Feature: Subaligner CLI
| subaligner | single |
| subaligner | dual |

@no-stretch
Scenario Outline: Test dual-stage alignment without stretch
@stretch
Scenario Outline: Test dual-stage alignment with stretch on
Given I have a video file "test.mp4"
And I have a subtitle file "test.srt"
When I run the alignment with <aligner> on them with <mode> stage and without stretch
When I run the alignment with <aligner> on them with <mode> stage and with stretch on
Then a new subtitle file "test_aligned.srt" is generated
Examples:
| aligner | mode |
Expand Down
138 changes: 69 additions & 69 deletions tests/integration/feature/subaligner_train.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,72 @@ Feature: Subaligner CLI
When I run the subaligner_train to display the finished epochs
Then it shows the done epochs equal to 2

# @train @bi-lstm
# Scenario: Test training on the Bidirectional LSTM network
# Given I have an audiovisual file directory "av"
# And I have a subtitle file directory "sub"
# And I want to save the training output in directory "output"
# When I run the subaligner_train against them with the following options
# """
# -bs 10 -do 0.5 -e 3 -p 1 -fhs 10 -bhs 5,2 -lr 0.01 -nt bi_lstm -vs 0.3 -o adam
# """
# Then a model and a training log file are generated
# When I run the subaligner_train to display the finished epochs
# Then it shows the done epochs equal to 3
#
# @train @ignore-sound-effects
# Scenario: Test ignoring sound effects during on training
# Given I have an audiovisual file directory "av"
# And I have a subtitle file directory "sub"
# And I want to save the training output in directory "output"
# When I run the subaligner_train against them with the following options
# """
# -e 2 -nt lstm --sound_effect_start_marker "(" --sound_effect_end_marker ")"
# """
# Then a model and a training log file are generated
# When I run the subaligner_train to display the finished epochs
# Then it shows the done epochs equal to 2
#
# @train @ignore-sound-effects
# Scenario: Test erroring on sound_effect_end_marker used alone
# Given I have an audiovisual file directory "av"
# And I have a subtitle file directory "sub"
# And I want to save the training output in directory "output"
# When I run the subaligner_train against them with the following options
# """
# -e 2 -nt lstm --sound_effect_end_marker ")"
# """
# Then it exits with code "21"
#
# @train @embedded-subtitle
# Scenario: Test training on video with embedded subtitles
# Given I have an audiovisual file directory "av_embedded"
# And I want to save the training output in directory "output"
# When I run the subaligner_train with subtitle selector "embedded:stream_index=0,file_extension=srt" and the following options
# """
# -bs 10 -do 0.5 -e 2 -p 1 -fhs 10 -bhs 5,2 -lr 0.01 -nt lstm -vs 0.3 -o adam
# """
# Then the embedded subtitles are extracted into "av_embedded_subtitles"
# And a model and a training log file are generated
# When I run the subaligner_train to display the finished epochs
# Then it shows the done epochs equal to 2
#
# @hyperparameter-tuning @lstm
# Scenario: Test hyperparameter tuning on the LSTM network
# Given I have an audiovisual file directory "av"
# And I have a subtitle file directory "sub"
# And I want to save the training output in directory "output"
# When I run the subaligner_tune against them with the following flags
# | epoch_per_trail | trails | network_type |
# | 1 | 2 | lstm |
# Then a hyperparameter file is generated
#
# @hyperparameter-tuning @bi-lstm
# Scenario: Test hyperparameter tuning on the Bidirectional LSTM network
# Given I have an audiovisual file directory "av"
# And I have a subtitle file directory "sub"
# And I want to save the training output in directory "output"
# When I run the subaligner_tune against them with the following flags
# | epoch_per_trail | trails | network_type |
# | 2 | 1 | bi_lstm |
# Then a hyperparameter file is generated
@train @bi-lstm
Scenario: Test training on the Bidirectional LSTM network
Given I have an audiovisual file directory "av"
And I have a subtitle file directory "sub"
And I want to save the training output in directory "output"
When I run the subaligner_train against them with the following options
"""
-bs 10 -do 0.5 -e 3 -p 1 -fhs 10 -bhs 5,2 -lr 0.01 -nt bi_lstm -vs 0.3 -o adam
"""
Then a model and a training log file are generated
When I run the subaligner_train to display the finished epochs
Then it shows the done epochs equal to 3

@train @ignore-sound-effects
Scenario: Test ignoring sound effects during on training
Given I have an audiovisual file directory "av"
And I have a subtitle file directory "sub"
And I want to save the training output in directory "output"
When I run the subaligner_train against them with the following options
"""
-e 2 -nt lstm --sound_effect_start_marker "(" --sound_effect_end_marker ")"
"""
Then a model and a training log file are generated
When I run the subaligner_train to display the finished epochs
Then it shows the done epochs equal to 2

@train @ignore-sound-effects
Scenario: Test erroring on sound_effect_end_marker used alone
Given I have an audiovisual file directory "av"
And I have a subtitle file directory "sub"
And I want to save the training output in directory "output"
When I run the subaligner_train against them with the following options
"""
-e 2 -nt lstm --sound_effect_end_marker ")"
"""
Then it exits with code "21"

@train @embedded-subtitle
Scenario: Test training on video with embedded subtitles
Given I have an audiovisual file directory "av_embedded"
And I want to save the training output in directory "output"
When I run the subaligner_train with subtitle selector "embedded:stream_index=0,file_extension=srt" and the following options
"""
-bs 10 -do 0.5 -e 2 -p 1 -fhs 10 -bhs 5,2 -lr 0.01 -nt lstm -vs 0.3 -o adam
"""
Then the embedded subtitles are extracted into "av_embedded_subtitles"
And a model and a training log file are generated
When I run the subaligner_train to display the finished epochs
Then it shows the done epochs equal to 2

@hyperparameter-tuning @lstm
Scenario: Test hyperparameter tuning on the LSTM network
Given I have an audiovisual file directory "av"
And I have a subtitle file directory "sub"
And I want to save the training output in directory "output"
When I run the subaligner_tune against them with the following flags
| epoch_per_trail | trails | network_type |
| 1 | 2 | lstm |
Then a hyperparameter file is generated

@hyperparameter-tuning @bi-lstm
Scenario: Test hyperparameter tuning on the Bidirectional LSTM network
Given I have an audiovisual file directory "av"
And I have a subtitle file directory "sub"
And I want to save the training output in directory "output"
When I run the subaligner_tune against them with the following flags
| epoch_per_trail | trails | network_type |
| 2 | 1 | bi_lstm |
Then a hyperparameter file is generated
4 changes: 2 additions & 2 deletions tests/integration/radish/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def run_subaligner_with_exit_segfail(step, aligner, mode):
step.context.exit_code = process.wait(timeout=WAIT_TIMEOUT_IN_SECONDS)


@when("I run the alignment with {aligner:S} on them with {mode:S} stage and without stretch")
def run_subaligner_without_stretch(step, aligner, mode):
@when("I run the alignment with {aligner:S} on them with {mode:S} stage and with stretch on")
def run_subaligner_with_stretch(step, aligner, mode):
if mode == "<NULL>":
process = subprocess.Popen([
os.path.join(PWD, "..", "..", "..", "bin", aligner),
Expand Down
67 changes: 67 additions & 0 deletions tests/subaligner/resource/accented.srt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
1
00:00:12,440 --> 00:00:14,955
J'ai passé près de deux décennies

2
00:00:14,979 --> 00:00:18,532
observer ce qui rend les gens plus chanceux que les autres

3
00:00:18,556 --> 00:00:22,119
et essayer d'aider les gens à augmenter leur chance.

4
00:00:22,675 --> 00:00:25,567
Vous voyez, j'enseigne l'entrepreneuriat,

5
00:00:25,591 --> 00:00:29,140
et nous savons tous que la plupart des nouvelles entreprises échouent,

6
00:00:29,164 --> 00:00:32,797
et les innovateurs et les entrepreneurs ont besoin de toute la chance possible.

7
00:00:33,846 --> 00:00:35,136
Alors, qu'est-ce que la chance ?

8
00:00:35,160 --> 00:00:41,200
La chance est définie comme un succès ou un échec apparemment causé par le hasard.

9
00:00:42,295 --> 00:00:43,662
Apparemment.

dix
00:00:43,686 --> 00:00:45,321
C'est le mot clé.

11
00:00:46,353 --> 00:00:48,362
On dirait que c'est une chance

12
00:00:48,386 --> 00:00:53,544
car on voit rarement tous les leviers qui entrent en jeu pour donner de la chance aux gens.

13
00:00:53,568 --> 00:00:56,561
Mais j'ai réalisé, en regardant si longtemps,

14
00:00:56,585 --> 00:00:59,918
que la chance est rarement un coup de foudre,

15
00:00:59,942 --> 00:01:01,696
isolé et dramatique.

16
00:01:01,696 --> 00:01:01,697
(EFFET SONORE)

17
00:01:01,697 --> 00:01:01,698
(EFFET SONORE)

0 comments on commit 65f7271

Please sign in to comment.