Example #1
0
def main():
    args = parse_arguments()
    settings = {
        'inactivity_timeout': -1,  # Don't kill me after 30 seconds
        'interim_results': True,
        'timestamps': True
    }

    nodes = [
        watson_streaming.utilities.MicAudioGen(),
        watson_streaming.Transcriber(settings, args.credentials),
        # watson_streaming.utilities.Printer(),
        IBMWatsonAdapter(),
        DeepTaggerModule(),
        Printer()
    ]

    fluteline.connect(nodes)
    fluteline.start(nodes)

    try:
        while True:
            time.sleep(10)
    except KeyboardInterrupt:
        fluteline.stop(nodes)
Example #2
0
def get_pipeline(watson_settings, credentials, addr):
    return [
        watson_streaming.Transcriber(watson_settings, credentials),
        IBMWatsonAdapter(),
        nodes.Profiler('post_adapter'),
        nodes.Logger(addr),
        DeepTaggerModule(),
        nodes.Profiler('post_tagger'),
        nodes.DisfluenciesFilter(),
        nodes.ChangeFilter(),
    ]
Example #3
0
def main():
    args = parse_arguments()
    settings = {
        'interim_results': True,
    }

    nodes = [
        watson_streaming.utilities.FileAudioGen(args.audio_file),
        watson_streaming.Transcriber(settings, args.credentials),
        watson_streaming.utilities.Printer(),
    ]

    fluteline.connect(nodes)
    fluteline.start(nodes)

    try:
        with contextlib.closing(wave.open(args.audio_file)) as f:
            wav_length = f.getnframes() / f.getnchannels() / f.getframerate()
        # Sleep till the end of the file + some seconds slack
        time.sleep(wav_length + 5)
    finally:
        fluteline.stop(nodes)
Example #4
0
def main():
    args = directory
    settings = {
        'inactivity_timeout': -1,  # Don't kill me after 30 seconds
        'interim_results': True,
    }

    nodes = [
        watson_streaming.utilities.MicAudioGen(),
        watson_streaming.Transcriber(settings, directory),
        slu.Interpret(),
    ]

    fluteline.connect(nodes)
    fluteline.start(nodes)

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        pass
    finally:
        fluteline.stop(nodes)
def main():
    args = parse_arguments()
    settings = {
        'inactivity_timeout': -1,  # Don't kill me after 30 seconds
        'interim_results': True,
    }

    nodes = [
        watson_streaming.utilities.MicAudioGen(),
        watson_streaming.Transcriber(settings, args.credentials, None, None,
                                     args.parameters),
        watson_streaming.utilities.Printer(),
    ]

    fluteline.connect(nodes)
    fluteline.start(nodes)

    try:
        while True:
            time.sleep(10)
    except KeyboardInterrupt:
        pass
    finally:
        fluteline.stop(nodes)
Example #6
0
    def test_sanity(self):
        transcriber = watson_streaming.Transcriber(
            settings={'interim_results': True},
            apikey=self.apikey,
            hostname=self.hostname,
        )
        file_audio_gen = watson_streaming.utilities.FileAudioGen(AUDIO_PATH)

        pipeline = [file_audio_gen, transcriber]
        fluteline.connect(pipeline)
        fluteline.start(pipeline)

        while True:
            result = transcriber.output.get()
            if 'results' in result:
                transcript = result['results'][0]['alternatives'][0][
                    'transcript']
                expected = 'several tornadoes'
                if transcript.startswith(expected):
                    break
        else:
            raise AssertionError("Didn't get expected transcript")

        fluteline.stop(pipeline)