コード例 #1
0
    def test_syllabify_textgrid_raises_error_with_invalid_preference(self):
        tg = textgrid.Textgrid()

        with self.assertRaises(errors.WrongOptionError) as _:
            praattools.syllabifyTextgrid(
                self.isle, tg, "words", "phones", "", stressDetectionErrorMode="bird"
            )
コード例 #2
0
def syllabifyTextgrids(tgPath, islePath):

    isleDict = isletool.LexicalTool(islePath)

    outputPath = join(tgPath, "syllabifiedTGs")
    utils.makeDir(outputPath)
    skipLabelList = ["<VOCNOISE>", "xx", "<SIL>", "{B_TRANS}", '{E_TRANS}']

    for fn in utils.findFiles(tgPath, filterExt=".TextGrid"):

        if os.path.exists(join(outputPath, fn)):
            continue

        tg = tgio.openTextgrid(join(tgPath, fn))
        
        syllableTG = praattools.syllabifyTextgrid(isleDict, tg, "words",
                                                  "phones",
                                                  skipLabelList=skipLabelList)
        
        outputTG = tgio.Textgrid()
        outputTG.addTier(tg.tierDict["words"])
        outputTG.addTier(tg.tierDict["phones"])
#         outputTG.addTier(syllableTG.tierDict["syllable"])
        outputTG.addTier(syllableTG.tierDict["tonic"])
        
        outputTG.save(join(outputPath, fn))
コード例 #3
0
def syllabifyTextgrids(tgPath, islePath):

    isleDict = isletool.LexicalTool(islePath)

    outputPath = join(tgPath, "syllabifiedTGs")
    utils.makeDir(outputPath)
    skipLabelList = ["<VOCNOISE>", "xx", "<SIL>", "{B_TRANS}", '{E_TRANS}']

    for fn in utils.findFiles(tgPath, filterExt=".TextGrid"):

        if os.path.exists(join(outputPath, fn)):
            continue

        tg = tgio.openTextgrid(join(tgPath, fn))

        syllableTG = praattools.syllabifyTextgrid(isleDict,
                                                  tg,
                                                  "words",
                                                  "phones",
                                                  skipLabelList=skipLabelList)

        outputTG = tgio.Textgrid()
        outputTG.addTier(tg.tierDict["words"])
        outputTG.addTier(tg.tierDict["phones"])
        #         outputTG.addTier(syllableTG.tierDict["syllable"])
        outputTG.addTier(syllableTG.tierDict["tonic"])

        outputTG.save(join(outputPath, fn))
コード例 #4
0
    def test_syllabify_textgrid(self):
        tgAsDict = {
            "xmin": 0,
            "xmax": 10,
            "tiers": [
                {
                    "name": "words",
                    "class": "IntervalTier",
                    "xmin": 0,
                    "xmax": 10,
                    "entries": [
                        (0.5, 1.5, "purple"),
                        (1.5, 2.1, "cat"),
                    ],
                },
                {
                    "name": "phones",
                    "class": "IntervalTier",
                    "xmin": 0,
                    "xmax": 10,
                    "entries": [
                        # Purple
                        (0.5, 0.75, "p"),
                        (0.75, 1.0, "ɝ"),
                        (1.0, 1.25, "ɹ"),
                        (1.25, 1.3, "p"),
                        (1.3, 1.50, "l"),
                        # Cat
                        (1.5, 1.7, "k"),
                        (1.7, 1.9, "æ"),
                        (1.9, 2.1, "t"),
                    ],
                },
            ],
        }
        tg = textgrid._dictionaryToTg(tgAsDict, "error")

        sut = praattools.syllabifyTextgrid(self.isle, tg, "words", "phones")
        syllableTier = sut.tierDict["syllable"]

        # Time is divided proportionally
        self.assertEqual(
            [
                # Purple
                Interval(0.5, 1.25, "p-ɝ-ɹ"),
                Interval(1.25, 1.5, "p-l"),
                # Cat
                Interval(1.5, 2.1, "k-æ-t"),
            ],
            syllableTier.entryList,
        )
コード例 #5
0
ファイル: test.py プロジェクト: the-maverick-lab/pysle
def createSyllabifiedTextgrid(names_audio, text_grid):

    isleDict = isletool.LexicalTool()

    tg = tgio.openTextgrid(text_grid)
    syllableTG = praattools.syllabifyTextgrid(isleDict,
                                              tg,
                                              "words",
                                              "phones",
                                              skipLabelList=[
                                                  "",
                                              ])
    tg.addTier(syllableTG.tierDict["syllable"])
    tg.addTier(syllableTG.tierDict["tonicSyllable"])
    tg.addTier(syllableTG.tierDict["tonicVowel"])

    tg.save('../mavid-scripts/files/wav_recordedNames_syllables_test.TextGrid')

    return
コード例 #6
0
from pysle import isletool
from pysle import praattools

root = join(".", "files")
isle = isletool.Isle(join(root, "ISLEdict_sample.txt"))

tg = textgrid.openTextgrid(join(root, "pumpkins.TextGrid"),
                           includeEmptyIntervals=False)

# Get the syllabification tiers and add it to the textgrid
syllableTG = praattools.syllabifyTextgrid(
    isle,
    tg,
    "word",
    "phone",
    skipLabelList=[
        "",
    ],
    stressDetectionErrorMode="warning",
    syllabificationErrorMode="warning",
)
tg.addTier(syllableTG.tierDict["syllable"])
tg.addTier(syllableTG.tierDict["tonicSyllable"])
tg.addTier(syllableTG.tierDict["tonicVowel"])

tg.save(
    join(root, "pumpkins_with_syllables.TextGrid"),
    format="short_textgrid",
    includeBlankSpaces=True,
)
コード例 #7
0
ファイル: syllabify_textgrid.py プロジェクト: sjoon2455/pysle
An example of how to syllabify a textgrid.

This code is an optional feature of pysle that requires the
praatio library.
'''

from os.path import join

from praatio import tgio
from pysle import isletool
from pysle import praattools

root = join('.', 'files')
isleDict = isletool.LexicalTool(join(root, "ISLEdict_sample.txt"))

tg = tgio.openTextgrid(join(root, "pumpkins.TextGrid"))

# Get the syllabification tiers and add it to the textgrid
syllableTG = praattools.syllabifyTextgrid(isleDict,
                                          tg,
                                          "word",
                                          "phone",
                                          skipLabelList=[
                                              "",
                                          ])
tg.addTier(syllableTG.tierDict["syllable"])
tg.addTier(syllableTG.tierDict["tonicSyllable"])
tg.addTier(syllableTG.tierDict["tonicVowel"])

tg.save(join(root, "pumpkins_with_syllables.TextGrid"))