Skip to content

Commit

Permalink
Use pyphen's list of languages as choice
Browse files Browse the repository at this point in the history
  • Loading branch information
Aymane Kssim committed Jan 14, 2024
1 parent 96626ce commit 4392daa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 2 additions & 1 deletion yohane/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import click
import torchaudio
from pyphen import LANGUAGES_LOWERCASE

from yohane.audio import (
HybridDemucsVocalsExtractor,
Expand Down Expand Up @@ -49,7 +50,7 @@
@click.option(
"-l",
"--language",
type=click.STRING,
type=click.Choice(list(LANGUAGES_LOWERCASE.keys()) + ["jp"], case_sensitive=False),
default="jp",
help="Language of the lyrics in ISO 639-1 norm. Default is Japanese (jp)."
)
Expand Down
7 changes: 1 addition & 6 deletions yohane/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ def syllables(self):
if self.language == 'jp':
res = auto_split(res)
else:
if self.language == 'en':
dic = pyphen.Pyphen(lang="en_EN")
elif self.language == 'fr':
dic = pyphen.Pyphen(lang="fr_FR")
else:
raise ValueError(f"Unsupported language {self.language}")
dic = pyphen.Pyphen(lang=self.language)
res = dic.inserted(res)
res = res.split("-")
return res
Expand Down

0 comments on commit 4392daa

Please sign in to comment.