From 4147b8a7a3a463911f1952444c1991530e748b7f Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Thu, 22 Sep 2022 13:38:24 -0400 Subject: [PATCH 01/20] readme --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 22fec08..d799212 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,8 @@ version = "2.0.1" description = "Forced alignment and vowel extraction" authors = ["FAVE contributors"] license = "GPL-3.0-only" +readme = "README.rst" +homepage = "https://github.com/JoFrhwld/FAVE" [tool.poetry.dependencies] python = ">=3.8,<4.0" From 638314eb0f9780f9c68cb828881d44a60660dfde Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Tue, 4 Oct 2022 09:58:45 -0400 Subject: [PATCH 02/20] update export script names for backwards compatibility --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index d799212..25608d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,3 +24,5 @@ build-backend = "poetry.masonry.api" [tool.poetry.scripts] fave-extract = "fave.extractFormants:main" fave-align = "fave.FAAValign:setup" +extractFormants = "fave.extractFormants:main" +FAAValign = "fave.FAAValign:setup" From f514fde449de40d495f0a176814d7c7ca47d834c Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Tue, 4 Oct 2022 10:18:00 -0400 Subject: [PATCH 03/20] incrementing version number --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 25608d8..61b6756 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fave" -version = "2.0.1" +version = "2.0.2" description = "Forced alignment and vowel extraction" authors = ["FAVE contributors"] license = "GPL-3.0-only" From 913d6c6e91e65366a86fac0a23396332f68e8641 Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Thu, 29 Sep 2022 10:05:33 +0200 Subject: [PATCH 04/20] removed the link to the mailing group --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9ba3b6a..c5d85a4 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ You can find user support for installing and using the FAVE toolkits at the [FAV ## Contributing to FAVE For the most part, we'll be utilizing the fork-and-pull paradigm (see [Using Pull Requests](https://help.github.com/articles/using-pull-requests)). Please send pull requests to the `dev` branch. -If you want to keep up to date on FAVE development, or have questions about FAVE development, send a request to join the [FAVE Developers' Group](https://groups.google.com/forum/#!forum/fave-dev). - ## Attribution [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.22281.svg)](http://dx.doi.org/10.5281/zenodo.22281) As of v1.1.3 onwards, releases from this repository will have a DOI associated with them through Zenodo. The DOI for the current release is [10.5281/zenodo.22281](http://dx.doi.org/10.5281/zenodo.22281). We would recommend the citation: From 614c5199cbba39f22426bd7a6064508f8b2a6507 Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Fri, 30 Sep 2022 08:07:44 +0200 Subject: [PATCH 05/20] added a bug reporting form --- .github/ISSUE_TEMPLATE/bug_report.yml | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..c593251 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,33 @@ +name: Bug Report +description: File a bug report here +title: "[BUG]: " +labels: ["bug"] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: checkboxes + id: new-bug + attributes: + label: Is there an existing issue for this? + description: Please search to see if an issue already exists for the bug you encountered. + options: + - label: I have searched the existing issues + required: true + - type: textarea + id: bug-description + attributes: + label: Description of the bug + description: Tell us what bug you encountered and what should have happened + validations: + required: true + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + placeholder: Please write the steps in a list form + validations: + required: true \ No newline at end of file From e21cef91191f0c6896f68721809281d32394794c Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Fri, 30 Sep 2022 08:13:59 +0200 Subject: [PATCH 06/20] added a link to the bug report form --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c5d85a4..8527f59 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ You can find user support for installing and using the FAVE toolkits at the [FAV ## Contributing to FAVE For the most part, we'll be utilizing the fork-and-pull paradigm (see [Using Pull Requests](https://help.github.com/articles/using-pull-requests)). Please send pull requests to the `dev` branch. +To fill a bug report, please follow this link [Bug Report](/.github/ISSUE_TEMPLATE/bug_report.yml) + ## Attribution [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.22281.svg)](http://dx.doi.org/10.5281/zenodo.22281) As of v1.1.3 onwards, releases from this repository will have a DOI associated with them through Zenodo. The DOI for the current release is [10.5281/zenodo.22281](http://dx.doi.org/10.5281/zenodo.22281). We would recommend the citation: From a865e50db65fb6b43442027215e2a04612c623ca Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Fri, 30 Sep 2022 08:48:57 +0200 Subject: [PATCH 07/20] added a description of bug triage --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8527f59..a722afb 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,9 @@ You can find user support for installing and using the FAVE toolkits at the [FAV ## Contributing to FAVE For the most part, we'll be utilizing the fork-and-pull paradigm (see [Using Pull Requests](https://help.github.com/articles/using-pull-requests)). Please send pull requests to the `dev` branch. -To fill a bug report, please follow this link [Bug Report](/.github/ISSUE_TEMPLATE/bug_report.yml) +You can fill in a bug report at the issue tab. + +We will work on the bugs with a bug triage. This means, that every bug is rated after its importance of fixing. Those bugs with the highest rating are solved first. This can lead to a bit dely in solving some bugs, but we will work on the most important first. ## Attribution [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.22281.svg)](http://dx.doi.org/10.5281/zenodo.22281) From 0a032426807e69edbdc9fdb0944daf1c16776272 Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Sat, 1 Oct 2022 12:45:14 +0200 Subject: [PATCH 08/20] added the changes to the bug report and readme --- .github/ISSUE_TEMPLATE/bug_report.yml | 21 ++++++++++++++------- Documents.code-workspace | 11 +++++++++++ README.md | 4 ++-- 3 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 Documents.code-workspace diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index c593251..75cc1e3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,5 +1,5 @@ name: Bug Report -description: File a bug report here +description: The software does something unwanted or unusual title: "[BUG]: " labels: ["bug"] @@ -11,23 +11,30 @@ body: - type: checkboxes id: new-bug attributes: - label: Is there an existing issue for this? + label: Did you search for similar bugs? description: Please search to see if an issue already exists for the bug you encountered. options: - label: I have searched the existing issues - required: true + required: false - type: textarea id: bug-description attributes: - label: Description of the bug - description: Tell us what bug you encountered and what should have happened + label: What happened? + description: Tell us what bug you encountered + validations: + required: true + - type: textarea + id: bug-behaviour + attributes: + label: Expectations? + description: Tell us what should have happened validations: required: true - type: textarea id: steps-to-reproduce attributes: label: Steps To Reproduce - description: Steps to reproduce the behavior. + description: Can you describe your steps, when you encountered the bug? placeholder: Please write the steps in a list form validations: - required: true \ No newline at end of file + required: false \ No newline at end of file diff --git a/Documents.code-workspace b/Documents.code-workspace new file mode 100644 index 0000000..d5ced89 --- /dev/null +++ b/Documents.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "../../.." + }, + { + "path": "../.." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/README.md b/README.md index a722afb..a9ba76c 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ You can find user support for installing and using the FAVE toolkits at the [FAV ## Contributing to FAVE For the most part, we'll be utilizing the fork-and-pull paradigm (see [Using Pull Requests](https://help.github.com/articles/using-pull-requests)). Please send pull requests to the `dev` branch. -You can fill in a bug report at the issue tab. +You can fill in a bug report at the [issue tab](https://github.com/JoFrhwld/FAVE/issues) -We will work on the bugs with a bug triage. This means, that every bug is rated after its importance of fixing. Those bugs with the highest rating are solved first. This can lead to a bit dely in solving some bugs, but we will work on the most important first. +There may be a delay between when a bug is reported and when a bug is resolved. Developers prioritize bugs based on difficulty, importance, and other factors, so bug reports are usually not handled in the order they are received. ## Attribution [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.22281.svg)](http://dx.doi.org/10.5281/zenodo.22281) From acbfb435ab79e63f46ed17249827b8eb943c938b Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Sun, 2 Oct 2022 09:53:17 +0200 Subject: [PATCH 09/20] deleted .code-workspace --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7d04f9b..5a4b3a8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.wav build/* docs/_build +*.code-workspace *.swp *.orig env From 6d95cd9896f876fd399a23670a3c371df9d45452 Mon Sep 17 00:00:00 2001 From: DerMoehre <94791958+DerMoehre@users.noreply.github.com> Date: Sun, 2 Oct 2022 09:52:01 +0200 Subject: [PATCH 10/20] Delete Documents.code-workspace --- Documents.code-workspace | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Documents.code-workspace diff --git a/Documents.code-workspace b/Documents.code-workspace deleted file mode 100644 index d5ced89..0000000 --- a/Documents.code-workspace +++ /dev/null @@ -1,11 +0,0 @@ -{ - "folders": [ - { - "path": "../../.." - }, - { - "path": "../.." - } - ], - "settings": {} -} \ No newline at end of file From 4e38a1e86c1ca731a1e9e809aececbd5b37e17ac Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Mon, 3 Oct 2022 12:57:43 +0200 Subject: [PATCH 11/20] added the test_readFile and updated the code in read_transcription_file to detec header --- fave/align/transcriptprocessor.py | 16 +++- tests/fave/align/test.csv | 140 ++++++++++++++++++++++++++++++ tests/fave/align/test_readFile.py | 88 +++++++++++++++++++ 3 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 tests/fave/align/test.csv create mode 100644 tests/fave/align/test_readFile.py diff --git a/fave/align/transcriptprocessor.py b/fave/align/transcriptprocessor.py index d9a2d95..bf32834 100644 --- a/fave/align/transcriptprocessor.py +++ b/fave/align/transcriptprocessor.py @@ -33,6 +33,7 @@ import re import sys import os +import csv import logging from fave import cmudictionary @@ -246,8 +247,19 @@ def preprocess_transcription(self, line): def read_transcription_file(self): """Reads file into memory""" with open(self.file) as f: - lines = self.replace_smart_quotes(f.readlines()) - self.lines = lines + try: + lines = self.replace_smart_quotes(f.readlines()) + float(lines[0].split('\t')[2]) + except ValueError: + # Log a warning about having detected a header row + print("Header row was detected") + # check, if there is a next line + try: + # jump to the next line of the file + next(f) + except: + pass + self.lines = lines # substitute any 'smart' quotes in the input file with the corresponding # ASCII equivalents (otherwise they will be excluded as out-of- diff --git a/tests/fave/align/test.csv b/tests/fave/align/test.csv new file mode 100644 index 0000000..c670ccc --- /dev/null +++ b/tests/fave/align/test.csv @@ -0,0 +1,140 @@ +Test Test Test +1 1 1 +2 3 2 +3 5 3 +4 7 4 +5 9 5 +6 11 6 +7 13 7 +8 15 8 +9 17 9 +10 19 10 +11 21 11 +12 23 12 +13 25 13 +14 27 14 +15 29 15 +16 31 16 +17 33 17 +18 35 18 +19 37 19 +20 39 20 +21 41 21 +22 43 22 +23 45 23 +24 47 24 +25 49 25 +26 51 26 +27 53 27 +28 55 28 +29 57 29 +30 59 30 +31 61 31 +32 63 32 +33 65 33 +34 67 34 +35 69 35 +36 71 36 +37 73 37 +38 75 38 +39 77 39 +40 79 40 +41 81 41 +42 83 42 +43 85 43 +44 87 44 +45 89 45 +46 91 46 +47 93 47 +48 95 48 +49 97 49 +50 99 50 +51 101 51 +52 103 52 +53 105 53 +54 107 54 +55 109 55 +56 111 56 +57 113 57 +58 115 58 +59 117 59 +60 119 60 +61 121 61 +62 123 62 +63 125 63 +64 127 64 +65 129 65 +66 131 66 +67 133 67 +68 135 68 +69 137 69 +70 139 70 +71 141 71 +72 143 72 +73 145 73 +74 147 74 +75 149 75 +76 151 76 +77 153 77 +78 155 78 +79 157 79 +80 159 80 +81 161 81 +82 163 82 +83 165 83 +84 167 84 +85 169 85 +86 171 86 +87 173 87 +88 175 88 +89 177 89 +90 179 90 +91 181 91 +92 183 92 +93 185 93 +94 187 94 +95 189 95 +96 191 96 +97 193 97 +98 195 98 +99 197 99 +100 199 100 +101 201 101 +102 203 102 +103 205 103 +104 207 104 +105 209 105 +106 211 106 +107 213 107 +108 215 108 +109 217 109 +110 219 110 +111 221 111 +112 223 112 +113 225 113 +114 227 114 +115 229 115 +116 231 116 +117 233 117 +118 235 118 +119 237 119 +120 239 120 +121 241 121 +122 243 122 +123 245 123 +124 247 124 +125 249 125 +126 251 126 +127 253 127 +128 255 128 +129 257 129 +130 259 130 +131 261 131 +132 263 132 +133 265 133 +134 267 134 +135 269 135 +136 271 136 +137 273 137 +138 275 138 +139 277 139 \ No newline at end of file diff --git a/tests/fave/align/test_readFile.py b/tests/fave/align/test_readFile.py new file mode 100644 index 0000000..3a8660e --- /dev/null +++ b/tests/fave/align/test_readFile.py @@ -0,0 +1,88 @@ +import logging +import pytest +from fave.align import transcriptprocessor +from fave import cmudictionary # We shouldn't be doing this... + +# Copied from ../test_cmudictionary.py +# which means this really should be made a fixture... +KWARGS = { + 'verbose': 1 + } + +CMU_EXCERPT = """ +TEST T EH1 S T +TEST'S T EH1 S T S +TESTA T EH1 S T AH0 +TESTAMENT T EH1 S T AH0 M AH0 N T +TESTAMENTARY T EH2 S T AH0 M EH1 N T ER0 IY0 +TESTED T EH1 S T AH0 D +TESTER T EH1 S T ER0 +TESTERMAN T EH1 S T ER0 M AH0 N +TESTERS T EH1 S T ER0 Z +TESTERS T EH1 S T AH0 Z +""" + +def test_read_transcription_file(tmp_path): + tmp_directory = tmp_path / "transcripts" + tmp_directory.mkdir() + tmp_file = tmp_directory / "test_transcript.csv" + dict_file = tmp_directory / "cmu.dict" + dict_file.write_text(CMU_EXCERPT) + cmu_dict = cmudictionary.CMU_Dictionary(dict_file, **KWARGS) + for test_case in provide_value_error_file(): + test_text = test_case[0] + flags = test_case[1] + expected = test_case[2] + tmp_file.write_text(test_text) + tp_obj = transcriptprocessor.TranscriptProcessor( + tmp_file, + cmu_dict, + **flags + ) + tp_obj.read_transcription_file() + + assert tp_obj.lines == expected + + for test_case in provide_no_error_file(): + test_text = test_case[0] + flags = test_case[1] + expected = test_case[2] + tmp_file.write_text(test_text) + tp_obj = transcriptprocessor.TranscriptProcessor( + tmp_file, + cmu_dict, + **flags + ) + tp_obj.read_transcription_file() + + assert tp_obj.lines == expected + +# this raises a ValueError, but it captured in the code +def provide_value_error_file(): + return [ + [ + "Style\tSpeaker\tBeginning\tEnd\tDuration\nFoo\tBar\t0.0\t3.2\t3.2", + { + 'prompt': "IDK what this is -CJB", + 'check' : '', + 'verbose': logging.DEBUG + }, + ['Style\tSpeaker\tBeginning\tEnd\tDuration\n', 'Foo\tBar\t0.0\t3.2\t3.2'] + ] + ] + +# this does not raise a ValueError +def provide_no_error_file(): + return [ + [ + "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\4.5\t3.5", + { + 'prompt': "IDK what this is -CJB", + 'check' : '', + 'verbose': logging.DEBUG + }, + ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\4.5\t3.5'] + ] + ] + + From 50bc9b5eb9cd61b9554b674d823d9ce50b3fd4b6 Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Wed, 5 Oct 2022 07:06:53 +0200 Subject: [PATCH 12/20] added the requested changes --- fave/align/transcriptprocessor.py | 8 +-- tests/fave/align/test_transcriptprocessor.py | 76 ++++++++++++++++++++ 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/fave/align/transcriptprocessor.py b/fave/align/transcriptprocessor.py index bf32834..1015c75 100644 --- a/fave/align/transcriptprocessor.py +++ b/fave/align/transcriptprocessor.py @@ -33,7 +33,6 @@ import re import sys import os -import csv import logging from fave import cmudictionary @@ -247,19 +246,20 @@ def preprocess_transcription(self, line): def read_transcription_file(self): """Reads file into memory""" with open(self.file) as f: + lines = self.replace_smart_quotes(f.readlines()) + self.lines = lines try: - lines = self.replace_smart_quotes(f.readlines()) float(lines[0].split('\t')[2]) except ValueError: # Log a warning about having detected a header row - print("Header row was detected") + self.logger.warning('Header row was detected') + del lines[0] # check, if there is a next line try: # jump to the next line of the file next(f) except: pass - self.lines = lines # substitute any 'smart' quotes in the input file with the corresponding # ASCII equivalents (otherwise they will be excluded as out-of- diff --git a/tests/fave/align/test_transcriptprocessor.py b/tests/fave/align/test_transcriptprocessor.py index 8854167..70a6c63 100644 --- a/tests/fave/align/test_transcriptprocessor.py +++ b/tests/fave/align/test_transcriptprocessor.py @@ -1,5 +1,27 @@ +import logging import pytest from fave.align import transcriptprocessor +from fave import cmudictionary # We shouldn't be doing this... + +# Copied from ../test_cmudictionary.py +# which means this really should be made a fixture... +KWARGS = { + 'verbose': 1 + } + +CMU_EXCERPT = """ +TEST T EH1 S T +TEST'S T EH1 S T S +TESTA T EH1 S T AH0 +TESTAMENT T EH1 S T AH0 M AH0 N T +TESTAMENTARY T EH2 S T AH0 M EH1 N T ER0 IY0 +TESTED T EH1 S T AH0 D +TESTER T EH1 S T ER0 +TESTERMAN T EH1 S T ER0 M AH0 N +TESTERS T EH1 S T ER0 Z +TESTERS T EH1 S T AH0 Z +""" + def test_replace_smart_quotes(): def test_func( testcase ): @@ -69,3 +91,57 @@ def provide_check_transcription_format_raises_value_error(): # Skip 5 entries (not an error) [ 'a\tb\tc\td\te\tf', ValueError], # 6 entries ] + +def test_read_transcription_file(tmp_path): + tmp_directory = tmp_path / "transcripts" + tmp_directory.mkdir() + tmp_file = tmp_directory / "test_transcript.csv" + dict_file = tmp_directory / "cmu.dict" + dict_file.write_text(CMU_EXCERPT) + cmu_dict = cmudictionary.CMU_Dictionary(dict_file, **KWARGS) + for test_case in provide_value_error_file(): + test_text = test_case[0] + flags = test_case[1] + expected = test_case[2] + tmp_file.write_text(test_text) + tp_obj = transcriptprocessor.TranscriptProcessor( + tmp_file, + cmu_dict, + **flags + ) + tp_obj.read_transcription_file() + + assert tp_obj.lines == expected + +def provide_value_error_file(): + return [ + [ # header row is detected and deleted + "Style\tSpeaker\tBeginning\tEnd\tDuration\nFoo\tBar\t0.0\t3.2\t3.2", + { + 'prompt': "IDK what this is -CJB", + 'check' : '', + 'verbose': logging.DEBUG + }, + ['Foo\tBar\t0.0\t3.2\t3.2'] + ], + [ # test with one line + "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\4.5\t3.5", + { + 'prompt': "IDK what this is -CJB", + 'check' : '', + 'verbose': logging.DEBUG + }, + ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\4.5\t3.5'] + ], + [ # test with more lines + "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\4.5\t3.5\nTest\t1.0\4.5\t3.5", + { + 'prompt': "IDK what this is -CJB", + 'check' : '', + 'verbose': logging.DEBUG + }, + ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\4.5\t3.5\n', 'Test\t1.0\4.5\t3.5'] + ] + + ] + From 08363126b0664afe21ccf96d3da03f323a9ccfcc Mon Sep 17 00:00:00 2001 From: DerMoehre <94791958+DerMoehre@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:58:29 +0200 Subject: [PATCH 13/20] Delete test.csv --- tests/fave/align/test.csv | 140 -------------------------------------- 1 file changed, 140 deletions(-) delete mode 100644 tests/fave/align/test.csv diff --git a/tests/fave/align/test.csv b/tests/fave/align/test.csv deleted file mode 100644 index c670ccc..0000000 --- a/tests/fave/align/test.csv +++ /dev/null @@ -1,140 +0,0 @@ -Test Test Test -1 1 1 -2 3 2 -3 5 3 -4 7 4 -5 9 5 -6 11 6 -7 13 7 -8 15 8 -9 17 9 -10 19 10 -11 21 11 -12 23 12 -13 25 13 -14 27 14 -15 29 15 -16 31 16 -17 33 17 -18 35 18 -19 37 19 -20 39 20 -21 41 21 -22 43 22 -23 45 23 -24 47 24 -25 49 25 -26 51 26 -27 53 27 -28 55 28 -29 57 29 -30 59 30 -31 61 31 -32 63 32 -33 65 33 -34 67 34 -35 69 35 -36 71 36 -37 73 37 -38 75 38 -39 77 39 -40 79 40 -41 81 41 -42 83 42 -43 85 43 -44 87 44 -45 89 45 -46 91 46 -47 93 47 -48 95 48 -49 97 49 -50 99 50 -51 101 51 -52 103 52 -53 105 53 -54 107 54 -55 109 55 -56 111 56 -57 113 57 -58 115 58 -59 117 59 -60 119 60 -61 121 61 -62 123 62 -63 125 63 -64 127 64 -65 129 65 -66 131 66 -67 133 67 -68 135 68 -69 137 69 -70 139 70 -71 141 71 -72 143 72 -73 145 73 -74 147 74 -75 149 75 -76 151 76 -77 153 77 -78 155 78 -79 157 79 -80 159 80 -81 161 81 -82 163 82 -83 165 83 -84 167 84 -85 169 85 -86 171 86 -87 173 87 -88 175 88 -89 177 89 -90 179 90 -91 181 91 -92 183 92 -93 185 93 -94 187 94 -95 189 95 -96 191 96 -97 193 97 -98 195 98 -99 197 99 -100 199 100 -101 201 101 -102 203 102 -103 205 103 -104 207 104 -105 209 105 -106 211 106 -107 213 107 -108 215 108 -109 217 109 -110 219 110 -111 221 111 -112 223 112 -113 225 113 -114 227 114 -115 229 115 -116 231 116 -117 233 117 -118 235 118 -119 237 119 -120 239 120 -121 241 121 -122 243 122 -123 245 123 -124 247 124 -125 249 125 -126 251 126 -127 253 127 -128 255 128 -129 257 129 -130 259 130 -131 261 131 -132 263 132 -133 265 133 -134 267 134 -135 269 135 -136 271 136 -137 273 137 -138 275 138 -139 277 139 \ No newline at end of file From 2293dbab2602172af3fb2f3cd207dd50f50d555f Mon Sep 17 00:00:00 2001 From: Moritz Dahm <94791958+DerMoehre@users.noreply.github.com> Date: Wed, 5 Oct 2022 07:24:28 +0200 Subject: [PATCH 14/20] Delete test_readFile.py --- tests/fave/align/test_readFile.py | 88 ------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 tests/fave/align/test_readFile.py diff --git a/tests/fave/align/test_readFile.py b/tests/fave/align/test_readFile.py deleted file mode 100644 index 3a8660e..0000000 --- a/tests/fave/align/test_readFile.py +++ /dev/null @@ -1,88 +0,0 @@ -import logging -import pytest -from fave.align import transcriptprocessor -from fave import cmudictionary # We shouldn't be doing this... - -# Copied from ../test_cmudictionary.py -# which means this really should be made a fixture... -KWARGS = { - 'verbose': 1 - } - -CMU_EXCERPT = """ -TEST T EH1 S T -TEST'S T EH1 S T S -TESTA T EH1 S T AH0 -TESTAMENT T EH1 S T AH0 M AH0 N T -TESTAMENTARY T EH2 S T AH0 M EH1 N T ER0 IY0 -TESTED T EH1 S T AH0 D -TESTER T EH1 S T ER0 -TESTERMAN T EH1 S T ER0 M AH0 N -TESTERS T EH1 S T ER0 Z -TESTERS T EH1 S T AH0 Z -""" - -def test_read_transcription_file(tmp_path): - tmp_directory = tmp_path / "transcripts" - tmp_directory.mkdir() - tmp_file = tmp_directory / "test_transcript.csv" - dict_file = tmp_directory / "cmu.dict" - dict_file.write_text(CMU_EXCERPT) - cmu_dict = cmudictionary.CMU_Dictionary(dict_file, **KWARGS) - for test_case in provide_value_error_file(): - test_text = test_case[0] - flags = test_case[1] - expected = test_case[2] - tmp_file.write_text(test_text) - tp_obj = transcriptprocessor.TranscriptProcessor( - tmp_file, - cmu_dict, - **flags - ) - tp_obj.read_transcription_file() - - assert tp_obj.lines == expected - - for test_case in provide_no_error_file(): - test_text = test_case[0] - flags = test_case[1] - expected = test_case[2] - tmp_file.write_text(test_text) - tp_obj = transcriptprocessor.TranscriptProcessor( - tmp_file, - cmu_dict, - **flags - ) - tp_obj.read_transcription_file() - - assert tp_obj.lines == expected - -# this raises a ValueError, but it captured in the code -def provide_value_error_file(): - return [ - [ - "Style\tSpeaker\tBeginning\tEnd\tDuration\nFoo\tBar\t0.0\t3.2\t3.2", - { - 'prompt': "IDK what this is -CJB", - 'check' : '', - 'verbose': logging.DEBUG - }, - ['Style\tSpeaker\tBeginning\tEnd\tDuration\n', 'Foo\tBar\t0.0\t3.2\t3.2'] - ] - ] - -# this does not raise a ValueError -def provide_no_error_file(): - return [ - [ - "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\4.5\t3.5", - { - 'prompt': "IDK what this is -CJB", - 'check' : '', - 'verbose': logging.DEBUG - }, - ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\4.5\t3.5'] - ] - ] - - From 8e245e3eefa954c61c4d8007ac89044ef8334bfc Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Wed, 5 Oct 2022 07:31:34 +0200 Subject: [PATCH 15/20] changes in the transcriptprocessor file --- fave/align/transcriptprocessor.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fave/align/transcriptprocessor.py b/fave/align/transcriptprocessor.py index 1015c75..34e0957 100644 --- a/fave/align/transcriptprocessor.py +++ b/fave/align/transcriptprocessor.py @@ -254,12 +254,6 @@ def read_transcription_file(self): # Log a warning about having detected a header row self.logger.warning('Header row was detected') del lines[0] - # check, if there is a next line - try: - # jump to the next line of the file - next(f) - except: - pass # substitute any 'smart' quotes in the input file with the corresponding # ASCII equivalents (otherwise they will be excluded as out-of- From f305e542737b466c9c5dc5555c722c29b0b0bc0e Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Wed, 5 Oct 2022 17:45:01 +0200 Subject: [PATCH 16/20] added the requested changes --- tests/fave/align/test_readFile.py | 88 ------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 tests/fave/align/test_readFile.py diff --git a/tests/fave/align/test_readFile.py b/tests/fave/align/test_readFile.py deleted file mode 100644 index 3a8660e..0000000 --- a/tests/fave/align/test_readFile.py +++ /dev/null @@ -1,88 +0,0 @@ -import logging -import pytest -from fave.align import transcriptprocessor -from fave import cmudictionary # We shouldn't be doing this... - -# Copied from ../test_cmudictionary.py -# which means this really should be made a fixture... -KWARGS = { - 'verbose': 1 - } - -CMU_EXCERPT = """ -TEST T EH1 S T -TEST'S T EH1 S T S -TESTA T EH1 S T AH0 -TESTAMENT T EH1 S T AH0 M AH0 N T -TESTAMENTARY T EH2 S T AH0 M EH1 N T ER0 IY0 -TESTED T EH1 S T AH0 D -TESTER T EH1 S T ER0 -TESTERMAN T EH1 S T ER0 M AH0 N -TESTERS T EH1 S T ER0 Z -TESTERS T EH1 S T AH0 Z -""" - -def test_read_transcription_file(tmp_path): - tmp_directory = tmp_path / "transcripts" - tmp_directory.mkdir() - tmp_file = tmp_directory / "test_transcript.csv" - dict_file = tmp_directory / "cmu.dict" - dict_file.write_text(CMU_EXCERPT) - cmu_dict = cmudictionary.CMU_Dictionary(dict_file, **KWARGS) - for test_case in provide_value_error_file(): - test_text = test_case[0] - flags = test_case[1] - expected = test_case[2] - tmp_file.write_text(test_text) - tp_obj = transcriptprocessor.TranscriptProcessor( - tmp_file, - cmu_dict, - **flags - ) - tp_obj.read_transcription_file() - - assert tp_obj.lines == expected - - for test_case in provide_no_error_file(): - test_text = test_case[0] - flags = test_case[1] - expected = test_case[2] - tmp_file.write_text(test_text) - tp_obj = transcriptprocessor.TranscriptProcessor( - tmp_file, - cmu_dict, - **flags - ) - tp_obj.read_transcription_file() - - assert tp_obj.lines == expected - -# this raises a ValueError, but it captured in the code -def provide_value_error_file(): - return [ - [ - "Style\tSpeaker\tBeginning\tEnd\tDuration\nFoo\tBar\t0.0\t3.2\t3.2", - { - 'prompt': "IDK what this is -CJB", - 'check' : '', - 'verbose': logging.DEBUG - }, - ['Style\tSpeaker\tBeginning\tEnd\tDuration\n', 'Foo\tBar\t0.0\t3.2\t3.2'] - ] - ] - -# this does not raise a ValueError -def provide_no_error_file(): - return [ - [ - "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\4.5\t3.5", - { - 'prompt': "IDK what this is -CJB", - 'check' : '', - 'verbose': logging.DEBUG - }, - ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\4.5\t3.5'] - ] - ] - - From 27c6fded80902e4aea08ab1e5faa38b850625402 Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Thu, 6 Oct 2022 06:23:38 +0200 Subject: [PATCH 17/20] typo correction --- tests/fave/align/test_transcriptprocessor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/fave/align/test_transcriptprocessor.py b/tests/fave/align/test_transcriptprocessor.py index 70a6c63..873d266 100644 --- a/tests/fave/align/test_transcriptprocessor.py +++ b/tests/fave/align/test_transcriptprocessor.py @@ -125,22 +125,22 @@ def provide_value_error_file(): ['Foo\tBar\t0.0\t3.2\t3.2'] ], [ # test with one line - "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\4.5\t3.5", + "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\t4.5\t3.5", { 'prompt': "IDK what this is -CJB", 'check' : '', 'verbose': logging.DEBUG }, - ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\4.5\t3.5'] + ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\t4.5\t3.5'] ], [ # test with more lines - "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\4.5\t3.5\nTest\t1.0\4.5\t3.5", + "Foo\tBar\t0.0\t3.2\t3.2\nTest\t1.0\t4.5\t3.5\nTest\t1.0\t4.5\t3.5", { 'prompt': "IDK what this is -CJB", 'check' : '', 'verbose': logging.DEBUG }, - ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\4.5\t3.5\n', 'Test\t1.0\4.5\t3.5'] + ['Foo\tBar\t0.0\t3.2\t3.2\n', 'Test\t1.0\t4.5\t3.5\n', 'Test\t1.0\t4.5\t3.5'] ] ] From 58b1adda184d1548e9a0a685bc6cd62f75048f11 Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Sun, 9 Oct 2022 12:45:14 +0200 Subject: [PATCH 18/20] added license and python badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a9ba76c..264c053 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ There may be a delay between when a bug is reported and when a bug is resolved. ## Attribution [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.22281.svg)](http://dx.doi.org/10.5281/zenodo.22281) +![GitHub](https://img.shields.io/github/license/JoFrhwld/FAVE) +![GitHub](https://img.shields.io/badge/Python-3.8%2B-brightgreen) As of v1.1.3 onwards, releases from this repository will have a DOI associated with them through Zenodo. The DOI for the current release is [10.5281/zenodo.22281](http://dx.doi.org/10.5281/zenodo.22281). We would recommend the citation: Rosenfelder, Ingrid; Fruehwald, Josef; Brickhouse, Christian; Evanini, Keelan; Seyfarth, Scott; Gorman, Kyle; Prichard, Hilary; Yuan, Jiahong; 2022. FAVE (Forced Alignment and Vowel Extraction) Program Suite v2.0.0 */zenodo.* From 5983ed6c41a46f1e5050ddae271a3ec570dbb812 Mon Sep 17 00:00:00 2001 From: DerMoehre Date: Sun, 9 Oct 2022 14:01:10 +0200 Subject: [PATCH 19/20] added a test for extractFormants --- tests/fave/extract/test_extractFormants.py | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/fave/extract/test_extractFormants.py diff --git a/tests/fave/extract/test_extractFormants.py b/tests/fave/extract/test_extractFormants.py new file mode 100644 index 0000000..147875e --- /dev/null +++ b/tests/fave/extract/test_extractFormants.py @@ -0,0 +1,50 @@ + +import logging +import pytest +import numpy as np +from fave import extractFormants + +def test_mean_stdv(): + for test_case in provide_valuelist(): + mean, stdv = extractFormants.mean_stdv(test_case[0]) + + assert mean == test_case[1] + assert stdv == test_case[2] + +def provide_valuelist(): + return [ + [ + [1, 2, 3, 4], + np.mean([1, 2, 3, 4]), + np.std([1, 2, 3, 4], ddof=1) + ], + [ + [3.5, 2.6, 11.6, 34.66, 2.8, 4.7], + np.mean([3.5, 2.6, 11.6, 34.66, 2.8, 4.7]), + np.std([3.5, 2.6, 11.6, 34.66, 2.8, 4.7], ddof=1) + ], + [ + [], + None, + None + ], + [ + [23, 34, 45, 56, 12, 312, 45, 943, 21, 1, 4, 6, 9, 2], + np.mean([23, 34, 45, 56, 12, 312, 45, 943, 21, 1, 4, 6, 9, 2]), + np.std([23, 34, 45, 56, 12, 312, 45, 943, 21, 1, 4, 6, 9, 2], ddof=1) + ], + [ + [3], + np.mean([3]), + 0 + ], + [ + [-1], + np.mean([-1]), + 0 + ] + + ] + + + From 3eca2653fdc78846a4de9c6fcc7f4ce709e6925d Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Mon, 10 Oct 2022 13:09:46 -0400 Subject: [PATCH 20/20] mean_stdv should ignore None or np.NAN --- tests/fave/extract/test_extractFormants.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/fave/extract/test_extractFormants.py b/tests/fave/extract/test_extractFormants.py index 147875e..e30ebe6 100644 --- a/tests/fave/extract/test_extractFormants.py +++ b/tests/fave/extract/test_extractFormants.py @@ -43,7 +43,14 @@ def provide_valuelist(): np.mean([-1]), 0 ] - + [ + [3.5, 2.6, 11.6, None, 34.66, 2.8, 4.7], + np.nanmean(np.array([3.5, 2.6, 11.6, None, 34.66, 2.8, 4.7], + dtype=np.float64)), + np.nanstd(np.array([3.5, 2.6, 11.6, None, 34.66, 2.8, 4.7], + dtype=np.float64), + ddof=1) + ] ]