annotations.CuedSpeech package

Submodules

annotations.CuedSpeech.keyrules module

filename

sppas.src.annotations.CuedSpeech.keyrules.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Parse a rule file of Cued Speech keys.

class annotations.CuedSpeech.keyrules.KeyRules(filename=None)[source]

Bases: object

Manager of a set of rules for syllabification of Cued Speech keys.

Format of the rules:

PHONCLASS i V PHONCLASS e V … PHONCLASS p C PHONCLASS t C PHONCLASS cnil C PHONCLASS vnil V

PHONKEY cnil 5 PHONKEY vnil s PHONKEY i m PHONKEY e t PHONKEY p 1 PHONKEY t 5 …

BREAK_SYMBOL = '#'
__init__(filename=None)[source]

Create a new instance.

Parameters

filename – (str) Name of the file with the rules.

get_class(phoneme)[source]

Return the class identifier of the phoneme.

If the phoneme is unknown, the break symbol is returned.

Parameters

phoneme – (str) A phoneme

Returns

class of the phoneme or break symbol

get_key(phoneme)[source]

Return the key identifier of the phoneme.

If the phoneme is unknown, None is returned. If the phoneme is a break, None is returned. If no key was defined for this phoneme, the “nil” key is returned.

Parameters

phoneme – (str) A phoneme

Returns

key of the phoneme or None

get_nil_consonant()[source]

Return the key code for a missing consonant.

get_nil_vowel()[source]

Return the key code for a missing vowel.

load(filename)[source]

Load the rules from a file.

Parameters

filename – (str) Name of the file with the rules.

Returns

(bool) Rules were appended or not

reset()[source]

Reset the set of rules.

syll_key(syll)[source]

Return the key codes matching the given syllable.

The given entry can be either of the form CV or C or V.

Parameters

syll – (str) A syllable like “p-a”, or “p” or “a”.

Returns

tuple(str, str) representing a CV key code

Raises

ValueError

annotations.CuedSpeech.lpckeys module

filename

sppas.src.annotations.CuedSpeech.lpckeys.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Keys generation of the Cued Speech from time-aligned phonemes.

class annotations.CuedSpeech.lpckeys.CuedSpeechKeys(keys_filename=None)[source]

Bases: object

Cued Speech keys generation from a sequence of phonemes.

__init__(keys_filename=None)[source]

Create a new LPC instance.

Load keys from a text file, depending on the language and phonemes encoding. See documentation for details about this file.

Parameters

keys_filename – (str) Name of the file with the list of keys.

keys_phonetized(phonetized_syllables)[source]

Return the keys of a phonetized syllable as C-V sequences.

The input string is using the X-SAMPA standard to indicate the phonemes and syllables segmentation.

>>> syllable = "e.p-a.R"
>>> lpc_keys = CuedSpeechKeys("fra-config-file")
>>> lpc_keys.keys_phonetized(syllable)
>>> "0-t.1-s.3-0"
Parameters

phonetized_syllables – (str) String representing the keys segments

Returns

(str)

static phonetize_syllables(phonemes, syllables)[source]

Return the phonetized sequence of syllables.

>>> phonemes = ['b', 'O~', 'Z', 'u', 'R']
>>> lpc_keys = CuedSpeechKeys("fra-config-file")
>>> syllables = lpc_keys.syllabify(phonemes)
>>> lpc_keys.phonetize_syllables(phonemes, syllables)
>>> "b-O~.Z-u.R"
Parameters
  • phonemes – (list) List of phonemes

  • syllables – list of tuples (begin index, end index)

Returns

(str) String representing the syllables segmentation

The output string is using the X-SAMPA standard to indicate the phonemes and syllables segmentation.

syll_to_key(phonetized_syllable)[source]

Return the key (c, v) of a phonetized syllable.

>>> syllable = "p-a"
>>> lpc_keys.syll_to_key(syllable)
>>> ("1", "s")   # consonant "1" then vowel "s"
Parameters

phonetized_syllable – (str) the phonemes of the syllable

Returns

(tuple)

syllabify(phonemes, durations=())[source]

Return the key boundaries of a sequence of phonemes.

Perform the segmentation of the sequence of phonemes into the syllables-structure of the LPC coding scheme. A syllable is CV, or V or C.

>>> phonemes = ['b', 'O~', 'Z', 'u', 'R']
>>> CuedSpeechKeys("fra-config-file").syllabify(phonemes)
>>> [ (0, 1), (2, 3), (4, 4) ]
Parameters
  • phonemes – (list of str) List of phonemes

  • durations – (list of float) List of phoneme’ durations

Returns

list of tuples (begin index, end index)

annotations.CuedSpeech.lpcvideo module

filename

sppas.src.annotations.CuedSpeech.lpcvideo.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Tag a video with the Cued Speech keys.

class annotations.CuedSpeech.lpcvideo.CuedSpeechVideoTagger(video=None, csv_sights=None)[source]

Bases: object

Create a video with hands tagged on the face of a video.

__init__(video=None, csv_sights=None)[source]

Create a new instance.

Parameters
  • video – (str) Filename of the input video

  • csv_sights – (str) Filename of the CSV with sights

close()[source]

Release video streams.

load(video, csv_sights)[source]

Open the video and load the CVS data.

Parameters
  • video – (str) Filename of the input video

  • csv_sights – (str) Filename of the CSV with sights

tag(syll_keys, output)[source]

Tag the video with the given keys.

Parameters
  • syll_keys – (sppasTier)

  • output – Output video filename

Returns

list of created files – expected 1

vowel_rank(vowel_code)[source]

Return an index from the code of a vowel or -1.

Parameters

vowel_code – (char) One of b, c, s, m, t

annotations.CuedSpeech.sppascuedspeech module

filename

sppas.src.annotations.CuedSpeech.sppascuedspeech.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

SPPAS integration of the Cued Speech automatic annotation.

class annotations.CuedSpeech.sppascuedspeech.sppasCuedSpeech(log=None)[source]

Bases: annotations.baseannot.sppasBaseAnnotation

SPPAS integration of the automatic Cued Speech key-code generation.

__init__(log=None)[source]

Create a new instance.

Log is used for a better communication of the annotation process and its results. If None, logs are redirected to the default logging system.

Parameters

log – (sppasLog) Human-readable logs.

convert(phonemes)[source]

Syllabify labels of a time-aligned phones tier.

Parameters

phonemes – (sppasTier) time-aligned phonemes tier

Returns

(sppasTier)

create_keys(lpc_tier)[source]

Return two tiers with the LPC keys from LPC syllables.

Parameters

lpc_tier – (sppasTier)

Returns

(sppasTier)

fix_options(options)[source]

Fix all options.

Available options are:

  • createvideo

Parameters

options – (sppasOption)

gen_keys_interval(tier_palign, from_p, to_p, lpc_keys)[source]

Perform the key generation of one sequence of phonemes.

Parameters
  • tier_palign – (sppasTier)

  • from_p – (int) index of the first phoneme to be syllabified

  • to_p – (int) index of the last phoneme to be syllabified

  • lpc_keys – (sppasTier)

static get_input_extensions()[source]

Extensions that the annotation expects for its input filename.

get_input_patterns()[source]

Pattern this annotation expects for its input filename.

get_output_pattern()[source]

Pattern this annotation uses in an output filename.

load_resources(config_filename, **kwargs)[source]

Fix the keys from a configuration file.

Parameters

config_filename – Name of the configuration file with the keys

make_video(video_file, landmarks, lpc_keys, output)[source]

Create a video with the LPC keys.

Parameters
  • video_file – (str) Filename of the video

  • landmarks – (str) Filename of the CSV with landmarks

  • lpc_keys – (sppasTier) Codes of the C-V syllables

run(input_files, output=None)[source]

Run the automatic annotation process on an input.

Parameters
  • input_files – (list of str) time-aligned phonemes, and optionally video, csv files

  • output – (str) the output name

Returns

(sppasTranscription)

set_create_video(create=True)[source]

Fix the createvideo option.

Parameters

create – (bool)

annotations.CuedSpeech.videokeys module

filename

sppas.src.annotations.CuedSpeech.videokeys.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Video buffer and writer for the Cued Speech keys.

class annotations.CuedSpeech.videokeys.sppasKeysImageWriter[source]

Bases: sppas.src.imgdata.sppasCoordsImageWriter

Tag&Write an image.

__init__()[source]

Create a new sppasSightsImageWriter instance.

Write the given image in the given filename. Five colors are fixed to draw the vowels positions:

  • Key of vowels 1 (“b”) is pink (200, 0, 100)

  • Key of vowels 2 (“c”) is orange (255, 128, 0)

  • Key of vowels 3 (“s”) is blue (0, 128, 255)

  • Key of vowels 4 (“m”) is red (205, 0, 0)

  • Key of vowels 5 (“t”) is green (0, 175, 0)

class annotations.CuedSpeech.videokeys.sppasKeysVideoBuffer(video=None, size=- 1)[source]

Bases: sppas.src.videodata.sppasCoordsVideoBuffer

A video buffer with lists of coordinates and keys.

For each image of the buffer, the coordinates is a list of the 5 positions of the vowels on a face and the key is a tuple with the Cued Speech key made of a consonant and a vowel identifier.

__init__(video=None, size=- 1)[source]

Create a new instance.

Parameters
  • video – (str) The video filename

  • size – (int) Number of images of the buffer or -1 for auto

get_key(buffer_index)[source]

Return the (consonant, vowel) key of a given image.

Parameters

buffer_index – (int) Index of the image in the buffer

Returns

tuple()

next()[source]

Override. Fill in the buffer with the next images & reset keys.

reset()[source]

Override. Reset all the info related to the buffer content.

set_key(buffer_index, consonant, vowel)[source]

Set the key to a given image index.

Parameters
  • buffer_index – (int) Index of the image in the buffer

  • consonant – (str) the given consonant

  • vowel – (str) the given vowel

class annotations.CuedSpeech.videokeys.sppasKeysVideoWriter(image_writer=None)[source]

Bases: sppas.src.videodata.sppasCoordsVideoWriter

Write a video with keys.

__init__(image_writer=None)[source]

Create a new instance.

get_vowel_rank(vowel_code)[source]

Return an index from the code of a vowel or -1.

Parameters

vowel_code – (char) One of b, c, s, m, t

set_vowels_rank(vrank)[source]

Set the rank of the vowels like used in the video buffer.

Parameters

vrank – (str) Each char is the key of a vowel position.

write_video(video_buffer, out_name, pattern)[source]

Save the result in video format.

Parameters
  • video_buffer – (sppasImage) The image to write

  • out_name – (str) The filename of the output video file

  • pattern – (str) Pattern to add to cropped video filename(s)

Returns

list of newly created video file names

Module contents

filename

sppas.src.annotations.CuedSpeech.__init__.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Cued Speech automatic annotation.

This package requires video feature, for opencv and numpy dependencies.

In French, Cued Speech is LfPC, the “Langue française Parlée Complétée”.

The conversion of phonemes into keys of LPC is performed using a rule-based system. This RBS phoneme-to-key segmentation system is based on the following principles:

  • a key is mainly of the form CV

  • a key can be C- or -V

class annotations.CuedSpeech.CuedSpeechKeys(keys_filename=None)[source]

Bases: object

Cued Speech keys generation from a sequence of phonemes.

__init__(keys_filename=None)[source]

Create a new LPC instance.

Load keys from a text file, depending on the language and phonemes encoding. See documentation for details about this file.

Parameters

keys_filename – (str) Name of the file with the list of keys.

keys_phonetized(phonetized_syllables)[source]

Return the keys of a phonetized syllable as C-V sequences.

The input string is using the X-SAMPA standard to indicate the phonemes and syllables segmentation.

>>> syllable = "e.p-a.R"
>>> lpc_keys = CuedSpeechKeys("fra-config-file")
>>> lpc_keys.keys_phonetized(syllable)
>>> "0-t.1-s.3-0"
Parameters

phonetized_syllables – (str) String representing the keys segments

Returns

(str)

static phonetize_syllables(phonemes, syllables)[source]

Return the phonetized sequence of syllables.

>>> phonemes = ['b', 'O~', 'Z', 'u', 'R']
>>> lpc_keys = CuedSpeechKeys("fra-config-file")
>>> syllables = lpc_keys.syllabify(phonemes)
>>> lpc_keys.phonetize_syllables(phonemes, syllables)
>>> "b-O~.Z-u.R"
Parameters
  • phonemes – (list) List of phonemes

  • syllables – list of tuples (begin index, end index)

Returns

(str) String representing the syllables segmentation

The output string is using the X-SAMPA standard to indicate the phonemes and syllables segmentation.

syll_to_key(phonetized_syllable)[source]

Return the key (c, v) of a phonetized syllable.

>>> syllable = "p-a"
>>> lpc_keys.syll_to_key(syllable)
>>> ("1", "s")   # consonant "1" then vowel "s"
Parameters

phonetized_syllable – (str) the phonemes of the syllable

Returns

(tuple)

syllabify(phonemes, durations=())[source]

Return the key boundaries of a sequence of phonemes.

Perform the segmentation of the sequence of phonemes into the syllables-structure of the LPC coding scheme. A syllable is CV, or V or C.

>>> phonemes = ['b', 'O~', 'Z', 'u', 'R']
>>> CuedSpeechKeys("fra-config-file").syllabify(phonemes)
>>> [ (0, 1), (2, 3), (4, 4) ]
Parameters
  • phonemes – (list of str) List of phonemes

  • durations – (list of float) List of phoneme’ durations

Returns

list of tuples (begin index, end index)

class annotations.CuedSpeech.CuedSpeechVideoTagger(*args, **kwargs)[source]

Bases: object

__init__(*args, **kwargs)[source]
class annotations.CuedSpeech.sppasCuedSpeech(*args, **kwargs)[source]

Bases: object

__init__(*args, **kwargs)[source]