How to use the asrtoolkit.data_handlers.json.dumps function in asrtoolkit

To help you get started, we’ve selected a few asrtoolkit 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 finos / greenkey-asrtoolkit / asrtoolkit / data_handlers / json.py View on Github external
:return: dict: key/val pairs contain 'segment'-level information
    """
    output_dict = {}
    output_dict["speakerInfo"] = seg.speaker
    output_dict["startTimeSec"] = float(seg.start)
    output_dict["endTimeSec"] = float(seg.stop)
    output_dict["genderInfo"] = {
        "gender": seg.label.split(",")[-1].replace(">", "")
    }
    output_dict["transcript"] = seg.text
    output_dict["confidence"] = seg.confidence

    if len(seg.formatted_text) > 0:
        output_dict["formatted_transcript"] = seg.formatted_text

    return json.dumps(output_dict, ensure_ascii=True)