Spaces:
Running
Running
File size: 1,305 Bytes
28d0c5f 74a35d9 0b0c1a6 74a35d9 28d0c5f 51b11b3 28d0c5f 51b11b3 28d0c5f 51b11b3 28d0c5f 51b11b3 28d0c5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import eng_to_ipa
from aip_trainer.models import ModelInterfaces
from aip_trainer import app_logger
class EpitranPhonemConverter(ModelInterfaces.ITextToPhonemModel):
word_locations_in_samples = None
audio_transcript = None
def __init__(self, epitran_model) -> None:
super().__init__()
self.epitran_model = epitran_model
def convertToPhonem(self, sentence: str) -> str:
app_logger.debug(f'starting EpitranPhonemConverter.convertToPhonem for sentence/token "{sentence}"...')
phonem_representation = self.epitran_model.transliterate(sentence)
app_logger.debug(f'EpitranPhonemConverter: got phonem_representation for sentence/token "{sentence}"!')
return phonem_representation
class EngPhonemConverter(ModelInterfaces.ITextToPhonemModel):
def __init__(self,) -> None:
super().__init__()
def convertToPhonem(self, sentence: str) -> str:
app_logger.debug(f'starting EngPhonemConverter.convertToPhonem for sentence/token "{sentence}"...')
phonem_representation = eng_to_ipa.convert(sentence)
phonem_representation = phonem_representation.replace('*','')
app_logger.debug(f'EngPhonemConverter: got phonem_representation for sentence/token "{sentence}"!')
return phonem_representation
|