def phone_sonority_level(phoneset, phone): if phoneset.phone_has_feature(phone, "vowel"): if phoneset.phone_has_feature(phone, "height_low"): return 9 elif phoneset.phone_has_feature(phone, "height_mid"): return 8 elif phoneset.phone_has_feature(phone, "height_high"): return 7 else: return 7 # diphtongs ? if phoneset.phone_has_feature(phone, "manner_liquid"): return 6 if phoneset.phone_has_feature(phone, "manner_nasal"): return 5 if phoneset.phone_has_feature(phone, "manner_fricative"): if phoneset.phone_has_feature(phone, "voiced"): return 4 else: return 3 if phoneset.phone_has_feature(phone, "manner_plosive"): if phoneset.phone_has_feature(phone, "voiced"): return 2 else: return 1 return 0
def phone_is_obstrudent(phoneset, phone): present_son = phoneset.phone_has_feature(phone, "class_sonorant") present_syl = phoneset.phone_has_feature(phone, "class_syllabic") present_cons = phoneset.phone_has_feature(phone, "class_consonantal") if (not present_son and not present_syl and present_cons): return True return False
def well_formed_onset_consonant_clusters(phoneset, c1, c2): cc = c1 + c2 # "s" clusters if c1 == "s": return test_phone_cluster(phoneset, cc, "wellformed_s_clusters") # plosive clusters if phoneset.phone_has_feature(c1, "manner_plosive"): return test_phone_cluster(phoneset, cc, "wellformed_plosive_clusters") # fricative clusters not /s/ if phoneset.phone_has_feature(c1, "manner_fricative"): return test_phone_cluster(phoneset, cc, "wellformed_fricative_clusters") return False
def get_all_nasals(phoneset): phones = phoneset.get_phone_list() nasals = [] for phone in phones: if phoneset.phone_has_feature(phone, "manner_nasal"): nasals.append(phone) return nasals
def get_all_glides(phoneset): phones = phoneset.get_phone_list() glides = [] for phone in phones: if phoneset.phone_has_feature(phone, "manner_glide"): glides.append(phone) return glides
def get_unvoiced_of_selection(phoneset, selection): phones = selection unvoiced = [] for phone in phones: if not phoneset.phone_has_feature(phone, "voiced"): unvoiced.append(phone) return unvoiced
def get_all_vowels(phoneset): phones = phoneset.get_phone_list() vowels = [] for phone in phones: if phoneset.phone_has_feature(phone, "vowel"): vowels.append(phone) return vowels
def get_all_plosives(phoneset): phones = phoneset.get_phone_list() consonants = [] for phone in phones: if phoneset.phone_has_feature(phone, "manner_plosive"): consonants.append(phone) return consonants
def get_all_consonants(phoneset): phones = phoneset.get_phone_list() consonants = [] for phone in phones: if phoneset.phone_has_feature(phone, "consonant"): consonants.append(phone) return consonants
def get_all_liquids(phoneset): phones = phoneset.get_phone_list() liquids = [] for phone in phones: if phoneset.phone_has_feature(phone, "manner_trill"): liquids.append(phone) continue if phoneset.phone_has_feature(phone, "manner_flap"): liquids.append(phone) continue t3 = phoneset.phone_has_feature(phone, "manner_approximant") t4 = phoneset.phone_has_feature(phone, "manner_liquid") if (t3 and t4): liquids.append(phone) return liquids
# load voice voice = speect.SVoice("/home/aby/Development/testing_voices/eng-ZA/voice.txt") # create a new utterance with the voice utt = speect.SUtterance(voice) # set utterance feature utt.features["name"] = "hrg example" # create a new "Segment" relation segment_rel = utt.relation_new("Segment") # add an item (pause = "#") for this voice item = segment_rel.append() item["name"] = "#" item = segment_rel.append() item["name"] = "a" # now we can get the voice from the item v = item.voice() # get the phoneset from the voice phoneset = v.data_get("phoneset") # get the vowel feature of item from phoneset print(phoneset.phone_has_feature("a", "vowel"))
import speect import speect.phoneset # load voice voice = speect.SVoice("/home/aby/Development/testing_voices/eng-ZA/voice.txt") # create a new utterance with the voice utt = speect.SUtterance(voice) # set utterance feature utt.features["name"] = "hrg example" # create a new "Segment" relation segment_rel = utt.relation_new("Segment") # add an item (pause = "#") for this voice item = segment_rel.append() item["name"] = "#" item = segment_rel.append() item["name"] = "a" # now we can get the voice from the item v = item.voice() # get the phoneset from the voice phoneset = v.data_get("phoneset") # get the vowel feature of item from phoneset print(phoneset.phone_has_feature("a", "vowel"))