Skip to content

Commit

Permalink
add manual phonemeisation by using <phoneme></phoneme> tags
Browse files Browse the repository at this point in the history
  • Loading branch information
korakoe committed Oct 9, 2024
1 parent 77acaad commit f8b3db5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions VoPho/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ def phonemize_for_language(self, text, lang):
:param lang: The language ID for phonemization
:return: Phonemized text, or original text wrapped in <??> tags if language is not supported
"""
phonemizer = self.get_phonemizer(lang)
if phonemizer:
return phonemizer.phonemize(text)
return f"<??>{text}</??>" # Return original text if no phonemizer available
if lang != "phoneme":
phonemizer = self.get_phonemizer(lang)
if phonemizer:
return phonemizer.phonemize(text)
return f"<??>{text}</??>" # Return original text if no phonemizer available
else:
return text

def phonemize(self, input_text, output_dict=False):
"""
Expand Down
1 change: 1 addition & 0 deletions VoPho/langtokenizers/multicoded.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'mr': 'red',
'he': 'white',
'th': 'blue',
'phoneme': 'blue',
'??': 'red'
}

Expand Down
2 changes: 1 addition & 1 deletion examples/phonemize_texts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from VoPho.engine import Phonemizer
from time import time

input_text = "I suppose i can, dont take my word for it though. 音素のテストを行うことは、発音の理解を深めるために重要です。"
input_text = "<phoneme>I suppose i can</phoneme>, dont take my word for it though. 音素のテストを行うことは、発音の理解を深めるために重要です。"

engine = Phonemizer()
start = time()
Expand Down

0 comments on commit f8b3db5

Please sign in to comment.