Exemplo n.º 1
0
 def getPrettyName(self):
     if len(self.params) >= 2:
         return _('dictionary {} / {}').format(
             languages.getName(self.params[0]),
             languages.getName(self.params[1]))
     else:
         super().getPrettyName()
Exemplo n.º 2
0
    def __init__(self, parent, streams, types):
        super().__init__(parent)

        img.setItemBitmap(self.m_bitmapTick, 'tickmark')
        img.setItemBitmap(self.m_bitmapCross, 'crossmark')

        self.streams = streams
        self.selection = []

        self.m_items.SetIconMap({
            False: img.getBitmap('crossmark'),
            True: img.getBitmap('tickmark')
        })

        for s in streams:
            self.m_items.InsertItem(os.path.basename(s.path), icon=False)

        self.m_choiceSelType.SetClientData(0, ['subtitle/text', 'audio'])
        self.m_choiceSelType.SetClientData(1, ['subtitle/text'])
        self.m_choiceSelType.SetClientData(2, ['audio'])

        stypes = set(s.type for ss in streams
                     for s in ss.streams.values()) & set(types)
        hasAudio = 'audio' in stypes
        hasSubtitle = 'subtitle/text' in stypes

        enableTypeSelection = hasAudio and hasSubtitle
        self.m_textSelType.Show(enableTypeSelection)
        self.m_choiceSelType.Show(enableTypeSelection)

        langs = set(
            canonizeLang(s.lang) for ss in streams
            for s in ss.streams.values() if s.type in types)
        self.m_choiceSelLang.Append(_('auto'), None)
        if '' in langs:
            langs.discard('')
            self.m_choiceSelLang.Append(_('<undefined>'), '')

        self.m_choiceSelLang.addSortedLangs(
            {languages.getName(l): l
             for l in langs})
        self.m_choiceSelLang.SetSelection(0)

        titles = set(s.title for ss in streams for s in ss.streams.values()
                     if s.type in types)
        self.m_choiceSelTitle.Append(_('auto'), None)
        for title in sorted(titles):
            value = title
            if title == '':
                title = _('<empty>')
            self.m_choiceSelTitle.Append(title, value)
        self.m_choiceSelTitle.SetSelection(0)

        self.m_textSelTitle.Show(len(titles) > 1)
        self.m_choiceSelTitle.Show(len(titles) > 1)

        self.onSelChange()

        self.Fit()
        self.Layout()
Exemplo n.º 3
0
def raiseNotSupportedAssets(assets):
    msg = []
    speech = [asset for asset in assets if asset.type == 'speech']
    dicts = [asset for asset in assets if asset.type == 'dict']

    if speech:
        langs = ', '.join([languages.getName(a.params[0]) for a in speech])
        msg += [ _('Synchronization with {} audio is currently not supported.') \
                .format(langs) ]

    if dicts:
        langs = [
            ' - '.join([languages.getName(p) for p in a.params]) for a in dicts
        ]
        msg += [ _('Synchronization between languages {} is currently not supported.') \
                .format(', '.join(langs)) ]

    msg += ['', _('missing assets:')]
    msg += [' - ' + asset.getPrettyName() for asset in assets]
    raise Error('\n'.join(msg))
Exemplo n.º 4
0
    def validate(self, localOnly=False):
        """Check if all assets on the list are available.

        Parameters
        ----------
        localOnly: bool, optional
            If `True` this method will check if all assets are installed
            locally, otherwise it will check if assets are available either
            locally or on asset server.

        Raises
        ------
        Error
            At least one asset is not available.
        """
        if localOnly:
            assets = self.notInstalled()
        else:
            assets = self.missing()

        if assets:
            msg = []
            speech = [asset for asset in assets if asset.type == 'speech']
            dicts = [asset for asset in assets if asset.type == 'dict']

            if speech:
                langs = ', '.join(
                    [languages.getName(a.params[0]) for a in speech])
                msg += [ _('Synchronization with {} audio is currently not supported.') \
                        .format(langs) ]
            if dicts:
                langs = [
                    ' - '.join([languages.getName(p) for p in a.params])
                    for a in dicts
                ]
                msg += [ _('Synchronization between languages {} is currently not supported.') \
                        .format(', '.join(langs)) ]

            msg += ['', _('missing assets:')]
            msg += [' - ' + asset.getPrettyName() for asset in assets]
            raise error.Error('\n'.join(msg))
Exemplo n.º 5
0
 def getPrettyName(self):
     return _('{} speech recognition model').format(
             languages.getName(self.params[0]))
Exemplo n.º 6
0
 def getPrettyName(self):
     return _('dictionary {} / {}').format(
             languages.getName(self.params[0]),
             languages.getName(self.params[1]))
Exemplo n.º 7
0
 def getPrettyName(self):
     if len(self.params) >= 1:
         return _('{} speech recognition model').format(
             languages.getName(self.params[0]))
     else:
         super().getPrettyName()