How to use the nltools.misc.init_app function in nltools

To help you get started, we’ve selected a few nltools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gooofy / zamia-speech / wiktionary_extract_ipa.py View on Github external
hyphenation = title

            ipa_cnt     += 1
            logging.info(u"%7d %7d %s IPA: %s" % (article_cnt, ipa_cnt, title, ipa))

            dictf.write('%s;%s\n' % (hyphenation, ipa))

            if ARTICLE_LIMIT and article_cnt >= ARTICLE_LIMIT:
                logging.warn('DEBUG limit of %d reached -> exit.' % ARTICLE_LIMIT)
                sys.exit(0)

#
# init
#

misc.init_app(PROC_TITLE)

#
# command line
#

parser = OptionParser("usage: %%prog [options]")

parser.add_option ("-l", "--lang", dest="lang", type = "str", default="de",
                   help="language (default: de)")

parser.add_option("-v", "--verbose", action="store_true", dest="verbose", 
                  help="enable debug output")

(options, args) = parser.parse_args()

if options.verbose:
github gooofy / zamia-ai / ai_cli.py View on Github external
for lang in LANGUAGES:
                s += '%3s:%9d (%5.1f%%)' % (lang, stats[m][lang], stats[m][lang]*100.0/totals[lang])
    
            stats2.append((s, stats[m]['en']))

        for t in sorted(stats2, key=lambda tup: tup[1]):
            logging.info(t[0])

        logging.getLogger().setLevel(DEFAULT_LOGLEVEL)

#
# init terminal
#

misc.init_app('ai_cli')

#
# logging
#

logging.basicConfig(level=DEFAULT_LOGLEVEL)
logging.getLogger("requests").setLevel(logging.WARNING)

#
# run cli
#

aicli = AICli()
sys.exit(aicli.main(loop=cmdln.LOOP_IF_EMPTY))
github gooofy / zamia-speech / speech_deepspeech_export.py View on Github external
from optparse               import OptionParser
from StringIO               import StringIO

from nltools                import misc
from nltools.tokenizer      import tokenize

from speech_transcripts     import Transcripts

WORKDIR             = 'data/dst/speech/%s/deepspeech'
PROMPT_AUDIO_FACTOR = 1000

#
# init 
#

misc.init_app ('speech_deepspeech_export')

config = misc.load_config ('.speechrc')

#
# commandline parsing
#

parser = OptionParser("usage: %prog [options] )")

parser.add_option ("-d", "--debug", dest="debug", type='int', default=0,
                   help="limit number of transcripts (debug purposes only), default: 0 (unlimited)")
parser.add_option ("-l", "--lang", dest="lang", type = "str", default='de',
                   help="language (default: de)")
parser.add_option ("-v", "--verbose", action="store_true", dest="verbose",
                   help="enable verbose logging")
github gooofy / zamia-ai / ai_mqtt.py View on Github external
publish_state(client)

    except KeyboardInterrupt:
        raise
    except:
        logging.error('EXCEPTION CAUGHT %s' % traceback.format_exc())

    finally:
        msg_cond.release()

#
# init
#

misc.init_app(PROC_TITLE)

#
# config, cmdline
#

config = misc.load_config('.airc', defaults = DEFAULTS)

broker_host                    = config.get      ('mqtt',   'broker_host')
broker_port                    = config.getint   ('mqtt',   'broker_port')
broker_user                    = config.get      ('mqtt',   'broker_user')
broker_pw                      = config.get      ('mqtt',   'broker_pw')

ai_model                       = config.get      ('server', 'model')
lang                           = config.get      ('server', 'lang')
vf_login                       = config.get      ('server', 'vf_login')
rec_dir                        = config.get      ('server', 'rec_dir')
github gooofy / zamia-speech / import_mozde.py View on Github external
import codecs
import traceback
import logging
import csv

from optparse               import OptionParser
from nltools                import misc

PROC_TITLE        = 'moz_de_to_vf'
DEFAULT_NUM_CPUS  = 12

#
# init terminal
#

misc.init_app (PROC_TITLE)

#
# command line
#

parser = OptionParser("usage: %prog [options]")

parser.add_option ("-n", "--num-cpus", dest="num_cpus", type="int", default=DEFAULT_NUM_CPUS,
                   help="number of cpus to use in parallel, default: %d" % DEFAULT_NUM_CPUS)

parser.add_option ("-v", "--verbose", action="store_true", dest="verbose", 
                   help="enable debug output")

(options, args) = parser.parse_args()

if options.verbose:
github gooofy / zamia-speech / abook-kaldi-retrieve.py View on Github external
import numpy as np

from optparse import OptionParser

from nltools                import misc

WORKDIR          = 'data/dst/asr-models/kaldi/segmentation'

SAMPLE_RATE      = 16000

#
# init 
#

misc.init_app ('abook-kaldi-retrieve')

config = misc.load_config ('.speechrc')

#
# commandline parsing
#

parser = OptionParser("usage: %prog [options] srcdir")

parser.add_option ("-v", "--verbose", action="store_true", dest="verbose",
                   help="enable verbose logging")

(options, args) = parser.parse_args()

if options.verbose:
    logging.basicConfig(level=logging.DEBUG)
github gooofy / zamia-speech / import_mailabs.py View on Github external
import logging
import json

from optparse import OptionParser
from nltools  import misc

PROC_TITLE        = 'import_mailabs'
DEFAULT_NUM_CPUS  = 12

GENDERS           = set(['male', 'female'])

#
# init
#

misc.init_app(PROC_TITLE)

#
# commandline
#

parser = OptionParser("usage: %prog [options]")

parser.add_option ("-n", "--num-cpus", dest="num_cpus", type="int", default=DEFAULT_NUM_CPUS,
                   help="number of cpus to use in parallel, default: %d" % DEFAULT_NUM_CPUS)

parser.add_option ("-v", "--verbose", action="store_true", dest="verbose",
                   help="verbose output")

(options, args) = parser.parse_args()

if options.verbose:
github gooofy / zamia-speech / speech_lex_missing.py View on Github external
from nltools                import misc
from nltools.tokenizer      import tokenize
from nltools.phonetics      import ipa2xsampa, xsampa2ipa
from nltools.sequiturclient import sequitur_gen_ipa

from speech_transcripts     import Transcripts
from speech_lexicon         import Lexicon

SEQUITUR_MODEL  = 'data/models/sequitur-%s-latest'

#
# init 
#

misc.init_app ('speech_lex_missing')

#
# command line
#

parser = OptionParser("usage: %prog [options] [filter] lex corpus")

parser.add_option ("-g", "--generate", action="store_true", dest="generate", 
                   help="generate phoneme transcriptions using sequitur g2p")

parser.add_option ("-l", "--lang", dest="lang", type = "str", default='de',
                   help="language (default: de)")

parser.add_option ("-n", "--num-words", dest="num_words", type="int", default=50,
                   help="max number of missing words to report, default: 50")
github gooofy / zamia-speech / wav2letter_export.py View on Github external
from nltools.phonetics      import ipa2xsampa

from speech_lexicon         import Lexicon
from speech_transcripts     import Transcripts

APP_NAME            = 'speech_wav2letter_export'

LANGUAGE_MODELS_DIR = 'data/dst/lm'
ASR_MODELS_DIR      = 'data/dst/asr-models'


#
# main
#

misc.init_app(APP_NAME)

#
# commandline
#

parser = OptionParser("usage: %prog [options]     [  ... ]")

parser.add_option ("-d", "--debug", dest="debug", type='int', default=0, help="Limit number of sentences (debug purposes only), default: 0")

parser.add_option ("-l", "--lang", dest="lang", type = "str", default='de', help="language (default: de)")

parser.add_option ("-p", "--prompt-words", action="store_true", dest="prompt_words", help="Limit dict to tokens covered in prompts")

parser.add_option ("-v", "--verbose", action="store_true", dest="verbose", help="verbose output")

(options, args) = parser.parse_args()
github gooofy / zamia-speech / import_librispeech.py View on Github external
import codecs
import re
import logging

from optparse import OptionParser
from nltools  import misc

PROC_TITLE='librispeech_to_vf'

SUBSETS = set(['dev-clean', 'test-clean', 'train-clean-100', 'train-clean-360'])

#
# init
#

misc.init_app(PROC_TITLE)

#
# commandline
#

parser = OptionParser("usage: %prog [options]")

parser.add_option ("-v", "--verbose", action="store_true", dest="verbose",
                   help="verbose output")

(options, args) = parser.parse_args()

if options.verbose:
    logging.basicConfig(level=logging.DEBUG)
else:
    logging.basicConfig(level=logging.INFO)