Skip to content

Commit

Permalink
Fix bug in subset for sqlite (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcauliffe committed Jun 7, 2023
1 parent dcf8997 commit 26a675e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/source/changelog/changelog_2.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
2.2 Changelog
*************

2.2.13
======

- Fixes an issue in using sqlite during subset creation for training

2.2.12
======

Expand Down
3 changes: 3 additions & 0 deletions montreal_forced_aligner/command_line/mfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ def mfa_cli(ctx: click.Context) -> None:
auto_server = False
else:
auto_server = getattr(GLOBAL_CONFIG.global_profile, "auto_server", True)
if "--no_use_postgres" in sys.argv or not GLOBAL_CONFIG.current_profile.use_postgres:
run_check = False
auto_server = False
if auto_server:
start_server()
elif run_check:
Expand Down
12 changes: 10 additions & 2 deletions montreal_forced_aligner/corpus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,11 @@ def create_subset(self, subset: int) -> None:
session.query(Utterance.id)
.join(Utterance.speaker)
.filter(Speaker.dictionary_id == dict_id)
.filter(Utterance.text.op("~")(r" [^ ]+ "))
.filter(
Utterance.text.op("~")(r" [^ ]+ ")
if GLOBAL_CONFIG.current_profile.use_postgres
else Utterance.text.regexp_match(r" [^ ]+ ")
)
.filter(Utterance.ignored == False) # noqa
.order_by(Utterance.duration)
.limit(larger_subset_num)
Expand Down Expand Up @@ -1144,7 +1148,11 @@ def create_subset(self, subset: int) -> None:
# Get all shorter utterances that are not one word long
larger_subset_query = (
session.query(Utterance.id)
.filter(Utterance.text.op("~")(r"\s\S+\s"))
.filter(
Utterance.text.op("~")(r"\s\S+\s")
if GLOBAL_CONFIG.current_profile.use_postgres
else Utterance.text.regexp_match(r"\s\S+\s")
)
.filter(Utterance.ignored == False) # noqa
.order_by(Utterance.duration)
.limit(larger_subset_num)
Expand Down

0 comments on commit 26a675e

Please sign in to comment.