Пример #1
0
def test_grammar_multi():
    lm = LanguageModelList(
        LanguageModelList.grammar_from_path('pizza', pizza_grammar_path))
    with open('test_grammar_multi.log', 'w') as f:
        stress_recognition(url, {
            'credentials': credentials,
            'log_level': log_level,
            'max_wait_seconds': 600,
            'log_stream': f
        },
                           pizza_multi_wav,
                           lm, (0, 25),
                           10,
                           10,
                           assertion=multi_assertion)
Пример #2
0
          "myusername mypassword".format(argv[0]))
    print("  eg3: {} ws://127.0.0.1:8025/asr-server/asr "
          "/path/to/my/grammar /path/to/audio.wav".format(argv[0]))
    exit()


if __name__ == "__main__":
    ostream = open('log.txt', 'a')
    argc = len(argv)
    if argc != 4 and argc != 6:
        usage()

    url = argv[1]
    if os.path.isfile(argv[2]):
        lm = LanguageModelList(
            LanguageModelList.grammar_from_path('asdasdas', argv[2]))
    else:
        lm = LanguageModelList(LanguageModelList.from_uri(argv[2]))
    apath = argv[3]
    credentials = ("", "")
    if argc == 6:
        credentials = (argv[4], argv[5])

    asr = SpeechRecognizer(url,
                           credentials=credentials,
                           log_stream=ostream,
                           log_level="debug",
                           max_wait_seconds=600)
    asr.recognize(FileAudioSource(apath), lm)
    res = asr.wait_recognition_result()
    if res:
Пример #3
0
          "builtin:grammar/samples/phone".format(argv[0]))
    print("  eg2: {} wss://contact/cpqd/and/request/a/key/ "
          "builtin:slm/general myusername mypassword".format(argv[0]))
    exit()


if __name__ == "__main__":
    ostream = open('log.txt', 'a')
    argc = len(argv)
    if argc != 3 and argc != 5:
        usage()

    url = argv[1]
    if os.path.isfile(argv[2]):
        lm = LanguageModelList(
            LanguageModelList.grammar_from_path(os.path.basename(argv[2]),
                                                argv[2]))
    else:
        lm = LanguageModelList(LanguageModelList.from_uri(argv[2]))
    credentials = ("", "")
    if argc == 5:
        credentials = (argv[3], argv[4])

    asr = SpeechRecognizer(url,
                           credentials=credentials,
                           log_stream=ostream,
                           listener=PrinterListener(),
                           log_level="warning")

    with MicAudioSource() as mic:
        try:
            asr.recognize(mic, lm)