-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<TEI> | ||
<!-- To exclude any element from alignment, add the do-not-align="true" attribute to | ||
it, e.g., <p do-not-align="true">...</p>, or | ||
<s>Some text <foo do-not-align="true">do not align this</foo> more text</s> --> | ||
<text xml:lang="fra"> | ||
<body> | ||
<div type="page"> | ||
<p> | ||
<s><span silence="1000"></span>Bonjour.</s> | ||
<s>Je m'appelle Éric Joanis.</s> | ||
<s>Je suis <span silence="1382"></span> programmeur au sein <span silence="500"></span> de l'équipe des technologies pour les langues autochtones au CNRC.</s> | ||
</p> | ||
</div> | ||
<div type="page"> | ||
<p> | ||
<s>J'ai fait une bonne partie de ma carrière en traduction automatique statistique, mais maintenant cette approche est déclassée par l'apprentissage profond.</s> | ||
<s>En ce moment je travaille à l'alignement du hansard du Nunavut pour produire un corpus bilingue anglais-inuktitut.</s> | ||
<s>Ce corpus permettra d'entraîner la TA, neuronale ou statistique, ainsi que d'autres applications de traitement du langage naturel.</s> | ||
</p> | ||
<p> | ||
<s>En parallèle, j'aide à écrire des tests pour rendre le ReadAlong-Studio plus robuste.</s> | ||
</p> | ||
</div> | ||
</body> | ||
</text> | ||
</TEI> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
from unittest import main | ||
|
||
from lxml import etree | ||
from pydub import AudioSegment | ||
from utils import BasicTestCase | ||
|
||
from readalongs.cli import align | ||
|
||
|
||
class TestSilence(BasicTestCase): | ||
def test_basic_silence_insertion(self): | ||
output = os.path.join(self.tempdir, "silence") | ||
# Run align from xml | ||
results = self.runner.invoke( | ||
align, | ||
[ | ||
"-s", | ||
"-C", | ||
"-t", | ||
"-l", | ||
"fra", | ||
os.path.join(self.data_dir, "ej-fra-silence.xml"), | ||
os.path.join(self.data_dir, "ej-fra.m4a"), | ||
output, | ||
], | ||
) | ||
self.assertEqual(results.exit_code, 0) | ||
self.assertTrue(os.path.exists(os.path.join(output, "silence.wav"))) | ||
# test silence spans in output xml | ||
with open(os.path.join(output, "silence.xml"), "rb") as f: | ||
xml_bytes = f.read() | ||
root = etree.fromstring(xml_bytes) | ||
silence_spans = root.xpath("//*[@silence]") | ||
self.assertEqual(len(silence_spans), 3) | ||
# test audio has correct amount of silence added | ||
original_audio = AudioSegment.from_file( | ||
os.path.join(self.data_dir, "ej-fra.m4a") | ||
) | ||
new_audio = AudioSegment.from_wav(os.path.join(output, "silence.wav")) | ||
self.assertEqual(len(new_audio) - len(original_audio), 2882) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |